Second, find the path in the system variable, then click "Edit", and the path variable indicates that the system can recognize the Java command under no path.
Then change the measure (N) to write ".; %java_home%\bin ". (the "%java_home%" means to set the value of Java_home just now). can also write "C:\jdk1.7\bin" directly. It is recommended to use the former. High reusability. Third, click "New", and then write the Classpath,classpath variable on the variable name to indicate the Java load class or lib path. There are only classes in classpath. Java Command talent recognition. Then change the measure (N) to write ".; %java_home%\lib \dt.jar;%java_home%\lib\toos.jar "(To Add. Indicates the current path) last. The Java Settings environment variable is complete, press OK until the property form disappears, that is, the save successfully verifies that the Java Settings environment variable is successful. Open Start, execute first. Enter "cmd" and go to the DOS system interface.
Then enter "Java-version", assuming the installation was successful. The system displays the Java version jdk "1.7.0". So the Java setting environment variable OK! Summary. Java Setting Environment variables purpose: 1,java_home(1) for the convenience of reference, such as your JDK installed in the C:\Program files\java\jdk1.7.0 folder, then set Java_home as the folder path, then you want to use this path, you just need to enter the%java_home% It is possible to avoid entering a very long path string for each reference;(2) A principle, when you need to change the JDK path, you just have to change the value of the Java_home variable, or you will change whatever the absolute path to refer to the JDK folder document, if you do not change, a program can not find the JDK, the consequences may be a program crash; (3) third-party software will refer to the agreed-java_home variable, before the normal use of the software, after a long time in Java will know that if a software does not work properly, it is likely that the java_home set incorrectly caused. 2,classpathThe purpose of setting up the classpath is to find the corresponding ". Class" File for the program, for example: Compile a Java program---a.java, you will get a A.class class file, run Java A in the current folder, you will get the corresponding result ( The premise is that you have setclasspath is "."). Now, moving A.class to another folder (such as "E:\"), running Java A, will throw a Java.lang.NoClassDefFoundError exception, because the. class file is not found, and now you add Classpath as: ".; E:\ "Execute Java A again, the result is all right, the Java command found the. class file through Classpath! 3. PATHDo you want to run JAVA commands at any time using%java_home%\bin\java and so on, of course not, so you can choose to add%java_home%\bin to the path, so that we can only use JAV for whatever path A to run the command. (When you enter your code in the command prompt form, the operating system looks for the corresponding application in the current folder and path variables folder, and it runs. ) three. Java Setting environment Variables-Error cases Error: Java.lang.NoClassDefFoundErrorDescriptive narrative: When a Java virtual machine or ClassLoader instance attempts to load in the definition of a class (as part of a typical method call or as part of a new instance created with a use new expression). This exception is thrown when the definition of the class cannot be found. Cause: Java Setting environment variable error
Java Setting environment variables