Previous--chapter1:1, Java language overview
Download Install JDK
-
Download JDK link from Oracle website
-
After the download is complete run the installation JDK, the personal likes installs under the D disk;
-
JDK Installation directory structure:
-
Bin: a command for storing tools, such as Javac,java;
-
DB: Install javadb path;
-
Include: platform-specific header files;
-
JRE: The JRE environment required to run the Java program;
-
LIB: The relevant jar dependency package;
-
Configure environment variables (WIN10):
-
Open in turn: Control Panel--System and security--system--Advanced system Setup--environment variable--system variable;
-
New, variable name: java_home, Variable value: D:\Program files\java\jdk1.8.0_131
-
Locate path, add:%java_home%\bin (note semicolon)
-
New, variable name: classpath, Variable value:.; %java_home%\lib\dt.jar;%java_home%\lib\toos.jar; Indicates the current path, used to force the Java interpreter to search for Java classes under the current path, and to separate variables.
-
Note that the Classpath,java command is configured to be recognized, and this place is prone to error, so be sure to pay attention.
-
To verify the installation:
Shortcut key Win+r Open Run--cmd, enter Java Run command, javac compile command or java-version, if display is successful installation, so easy!!!
?! installation Test
Set up the environment, we come to run a small program, which is what every programmer knows: HelloWorld
Install JDK with 1:linux environment:
-
Download the corresponding version of the JDK, usually the tar.gz suffix file;
-
Upload to the Linux environment/usr directory via XFTP client;
-
mkdir Java
CP jdk-8u161-linux-i586.tar.gz java/
?
4. Configure Environment variables:
?
"' Shell
Vim/etc/bashrc
#文件末尾添加
Export java_home=/usr/java/jdk1.8.0_161
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${java_home}/lib:${jre_home}/lib: $CLASSPATH
Export Java_path=${java_home}/bin:${jre_home}/bin
Export Path=${java_path}: $PATH
-
Execute the command to make the configuration effective:source /etc/bashrc
-
Enter java -version command to view Java version found error:
-bash:/usr/java/jdk1.8.0_161/bin/java:/lib/ld-linux.so.2:bad ELF interpreter:no such file or directory
This problem occurs because the JDK and the system version do not match.
-
Execute command: yum install glibc.i686 Resolve version issue, enter java -version discovery is installed correctly:
Java Version "1.8.0_161"
Java (TM) SE Runtime Environment (build 1.8.0_161-b12)
Java HotSpot (TM) Client VM (build 25.161-b12, Mixed mode)
?
Next--chapter1:3, the first Java program
?
2. Building Java Development environment