Install JDK, such as directory in C:\Java
In order to facilitate the development of Java programs, you need to configure the environment variables, right-click My Computer---Properties----environment variable----- User Variables in the [New (N)] Add the following environment variables
(Assuming that your JDK installation path is C:\Java\jdk1.6.0_30)
Java_home
C:\Java\jdk1.6.0_30
PATH
C:\Java\jdk1.6.0_30\bin
CLASSPATH
.; %java_home%\lib\dt.jar;%java_home%\lib\tools.jar; (Note the preceding dot and semicolon must not be lost, and the middle, the semicolon in the back should not be lost)
Description: Classpath can add some third-party jar files, which is convenient to compile and run the program manually.
You can test it once you've built it up separately.
Description: If the computer is only using the variables above, it is recommended to set the user variable.
A simple test program can be written using tools such as Notepad, saved in D:\, with the following code:
?
public class Test { public static void main(String[] args) { System.out.println( "Hello java!" ); } } |
Note: Keep in mind that the file name and class name are the same and the suffix name (. java)
Run cmd, enter the DOS interface, run java-version, and if the above environment is configured correctly, the current JDK version information should be displayed. (This command can be run in any directory)
Run Javac D:\Test.java, enter the same directory will compile the generated file Test.class,
Run D: Enter the D packing directory,
Run Java Text, enter output Hello java!