【text】
1. Install the JDK development environment
Download website: http://www.oracle.com/
Start installing JDK:
Modify the installation directory as follows:
After confirmation, click Next.
Note: When prompted to install JRE, you can choose not to install it.
2. Configure environment variables:
For Java program development, two commands of JDK are mainly used: javac.exe and java.exe. Path: C:/Java/jdk 1.7.0 _09/bin. However, since these commands do not belong to Windows' own commands, if you want to use them, you need to configure the path.
Click Computer-Properties-Advanced System Settings and click Environment Variables. Under the System Variables column, click New to create a new system environment variable.
(1) Create new -> variable name "JAVA_HOME", variable value "C:/Java/jdk1.8.0_05" (i.e. JDK installation path)
(2) Edit -> Variable name "Path", add ";%JAVA_HOME%/bin;%JAVA_HOME%/jre/bin" at the end of the original variable value
(3) Create new -> variable name "CLASSPATH", variable value ".;%JAVA_HOME%/lib;%JAVA_HOME%/lib/dt.jar;%JAVA_HOME%/lib/tools.jar"
For example: The operation of the JAVA_HOME environment variable is as follows:
3. Confirm whether the environment configuration is true:
Enter the java, javac, and java -version commands in the console, and the JDK compiler information shown below appears, including syntax and parameter options for modifying the command.
java command:
javac command:
java -version command:
4. Verify the first java program under the console:
Copy the code as follows: public class Test { public static void main(String[] args) { Systemm.out.println("Hello Java"); }}
Write it in Notepad, click "Save", and save it into the root directory of the C disk, enter the javac Test.java and java Test commands to run the program (print out the result "Hello Java"). Note: These two commands are in the D:/java/jdk1.8.0_20/bin directory.
Program analysis:
First write the java source code program with the extension.java;
In command line mode, enter the command: javac source file name.java, compile the source code, and generate a class bytecode file;
After compilation is completed, if there is no error message, enter the command: java HelloWorld to interpret and run the class bytecode file. There is no need to add the .class extension when executing. See the picture below:
Note: If you enter the javac test.java command in CMD, the 'javac' is not an internal or external command. The reason is that the JDK development environment was not installed in advance or the environment variable configuration was incorrect.
Related source code:
Source code location: D:/java/jdk1.8.0_20/src.zip
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.