Start the stepping stone of JAVA programming-JAVA Development Environment Construction and java stepping stone
Java programming from scratch-JAVA Development Environment Setup 1. What is a java Development Environment?
As the name suggests, the development environment of java is a necessary environment to provide and ensure the development and operation of the entire java program. Building a java development environment is a stepping stone for java programming. It is so clever that you can write cool code, there is no corresponding development environment, and it is also a bunch of unclear symbols.
When compiling or running a Java program, it is based on the command line. Therefore, you must set the value of some environment variables before this. Some Java IDES (integrated development environment) have built-in JDK, so you can use these ides without specifying environment variables. Some programs also require personalized environment variables (for example, Apache Tomcat requires JAVA_HOME environment variables ).
The java development environment mainly includes the following three packages:
JVM (Java Virtual Machine-Java Virtual Machine)
JRE (Java Runtime Environment-Java Runtime Environment)
JDK (Java Development kit-Java Development kit)
Among them, JDK is the most familiar and widely known. This is because JDK includes JRE and JVM, and JRE and JVM are installed after JDK is installed, the JDK installation package can be downloaded from the official Oracle website or from a third-party website.
2. Download and install JDK
Because JDK includes JRE and JVM, after JDK is installed, the first step to build the java development environment is completed!
1.
Official Website: http://www.oracle.com/technetwork/java/javase/downloads/index.html
Click to go to the following download page:
This page contains the JDK Download Links for various operating systems. Select the JDK corresponding to your system and download it to the local hard disk. Note: before downloading, read "Oracle Binary Code License Agreement for Java SE". RequiredAcceptOnly the JDK can be downloaded under the terms.(Select "Accept License Agreement ").
Note: the operating system is divided into 32-bit and 64-bit operating systems, JDK is also divided into 32-bit version and 64-bit version (the 32-bit version with "i586" or "x86" in the name, "x64" indicates that JDK is a 64-bit version ). 64-bit JDK can only be installed on 64-bit operating systems. 32-bit JDK can be installed on both 32-bit operating systems and 64-bit operating systems. The reason is that the 64-bit operating system is compatible with 32-bit applications.
In other words, even if the CPU is 64-bit but the operating system is 32-bit, the 64-bit JDK cannot be installed.
2. Installation Steps
Installing JDK on Windows or Linux is simple, and it is no different from installing other programs.
In WindowsTo download the jdk-7-windows-i586.exe file. Next step during installation.
Note: The default installation location is drive C. Remember to use the jdk installation location for the following environment setup!
Go to the installation folder to view the directory structure of the installed JDK.(Note that it contains a folder named "jre", which is the reason why JDK contains JRE)
The entire installation process is shown in the following figure (I have already installed it, and the figure I found on the Internet should be similar ):
In LinuxInstall JDK is the same as install other programs. When downloading, you can select the installation file in the format of .rpmor .tar.gz.
(Note: For other zip and rar compressed files, you must install a plug-in linux to decompress the files)In the following example.
First extract the downloaded file, cd it to the directory of the downloaded file, and then enter the command "tar-zxvf your downloaded file name .tar.gz" to decompress the file
Current DirectoryTo complete the installation.
(Note: You can use other tar command parameters to customize the location where you want to install the tool. Here we will not explain it too much)
3. Set up environment variables
Environment variables are some parameters used to specify the operating system runtime environment in the operating system, such as the Temporary Folder location and system folder location. Environment variables are equivalent to some parameters set for the system or application.
Environment variables such as PATH and CLASSPATH are related to JDK or JRE usage. Here we will first explain the meanings of these variables:
JAVA_HOME is usedConfigure the JDK installation path.
PATH variableIt is used to tell the operating system where to find a command. If you clear the value of the PATH variable and run an external command in Windows, an unknown command error is prompted (of course, the same is true in Linux)
Note: In Windows, commands such as "dir" and "cd" are internal commands, similar to the resident commands in DOS. These commands are automatically loaded into the memory when the command line window is started, and do not need to go to the disk to find the corresponding executable file, therefore, even if the value of the PATH variable is cleared, the use of these commands will not be affected. However, external commands such as "java" must first find the corresponding executable program from the operating system to the specified directory before they can be loaded and run. Where to find these programs depends on the PATH variable.
Linux is similar. in Linux, PATH environment variables are even more important, because many basic Linux commands belong to external commands, such as "ls" and "mkdir. After the PATH variable is cleared, these commands cannot be used (of course, some internal commands can still be used ).
CLASSPATHIt is used to tell the Java compiler or virtual machine where to find the Java class files when compiling or running Java programs.
Now we use Windows 10 as an example to set up the widows environment variable (for linux, we can also set up the environment variable ~)
1. Right-click my computer> Properties> advanced system Settings> advanced to open the environment variable settings window:
2. Create JAVA_HOME and edit it as follows (the variable value is the JDK installation path ):
3. PATH already exists in the system variable. Select PATH --> Edit
The variable value is % JAVA_HOME % \ bin; % JAVA_HOME % \ jre \ bin)
Note: Each environment variable is separated. JAVA_HOME is the configured JDK file directory.
4. the built-in variables do not have CLASSPATH and need to be created.
--> Use "." To represent the current path(It cannot be missed !!)
--> Separated ";"
--> Enter the absolute path of lib (for example, my absolute path is C: \ Program Files \ Java \ jdk1.8.0 _ 31 \ lib)
You can also separate the path of the jar package (in the figure, my configuration still uses the relative path of JAVA_HOME)
The variable value is:.; % JAVA_HOME % \ lib \ dt. jar; % JAVA_HOME % \ lib \ tools. jar;
The configuration ends here. Remember to press OK. If you are not sure, it will not be saved by yourself.
Note: In Windows, environment variables are divided into "User variables" and "system variables". The difference is that "User variables" only work for the current user, the "system variables" function for all users in the system. If you want to share environment variables among multiple users, you can set these environment variables as system variables. Otherwise, you should use user variables to avoid affecting other users.
Iii. Verify environment variable configuration
Open and run "à cmd à" and enter java/javac for verification (the verification is successful as follows)
The content is incomplete. Just jump out of a basket of stuff! Next we can start writing and running java programs ~ I wish you a better path to agriculture.
11:46:32