The usage method is as follows:
Install jdk first
Use WordPad to write the program and name it abc.java
where abc is The name of the public class in your file
Then the command line
javac abc.java
java abc
Prerequisite: the environment needs to be installed Variables
Right-click My Computer, select "Properties", select the "Advanced" tab, enter the environment variable settings, and set the following three environment variables:
Set JAVA_HOME: p>
First, for the convenience of reference, for example, if the JDK is installed in the C:\jdk1.6.0 directory, set JAVA_HOME as the directory path. Then when you want to use this path in the future, you only need to enter %JAVA_HOME% That’s it. Avoid entering a long path string for each reference;
The second is the principle of normalization. When the JDK path changes, you only need to change the variable value of JAVA_HOME. Otherwise, you need to change any document that uses an absolute path to reference the JDK directory. If it is not changed completely, a certain program cannot find the JDK, and the consequences are conceivable - the system crashes!
Third, the third-party software will reference the agreed JAVA_HOME variable. Otherwise, you will not be able to use the software normally.
Click in the system environment variable column -> Create a new JAVA_HOME variable. (JAVA_HOME points to the JDK installation path)
Variable name:?JAVA_HOME
Variable value:?C:\jdk1.6.0?
(1) Set the path variable so that we can run java applications anywhere in the system, such as javac, java, javah, etc. This requires finding the directory where we install the JDK.
Assume that our JDK is installed In the C:\jdk1.6.0 directory, then the C:?\jdk1.6.0\bin directory is our commonly used java application. We need to add the C:\jdk1.6.0\bin directory to the path environment variable in.
Find the path variable in the system variables and select ->Edit; (there are already many variable values ??in it, just add C:\jdk1.6.0\bin; at the front of the variable value? If not ?Just create a new one, but it usually exists)
Variable name:?path
Variable value:?C:\jdk1.6.0\bin;
Or?%JAVA_HOME%\bin;
(2) The classpath environment variable is used to let the java interpreter know where to find it when we need to reference a class written by others when developing a java program. this class. Usually, sun provides us with some additional rich class packages, one is dt.jar and the other is tools.jar. Both jar packages are located in the C:\jdk1.6.0\lib directory, so usually we will These two jar packages are added to our classpath environment variable set?classpath=.;C:\jdk1.6.0\lib\tools.jar;C:\jdk1.6.0\lib\dt.jar.
Click ->New classpath in the column of system environment variables
Variable name:?classpath
Variable value:?.;C:\jdk1. 6.0\lib\tools.jar;C:\jdk1.6.0\lib\dt.jar;
or?.;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\lib\dt. jar;
(Note that there is a "." at the front of CLASSPATH?, indicating the current directory, so when we run java?AClass, the system will first look for the AClass file in the current directory .
)?