Java environment variable settings

Source: Internet
Author: User
1. Java environment variable settings-lite version 1. right-click my computer and choose Properties> advanced> environment variable 2. create System variables java_home and classpath variable name (n): java_home variable value (V): c: \ Program Files \ Java \ jdk1.7.0 variable name (n): classpath variable value (V) :.; % java_home % \ Lib \ DT. jar; % java_home % \ Lib \ tools. jar; 3. select the environment variable named "path" in "system variables" and double-click the variable to add the absolute path of the bin directory in the JDK installation path to the value of the PATH variable, separate them with semicolons (;) and existing paths. Variable name (n): PATH variable value (V): % java_home % \ bin; % java_home % \ JRE \ bin; 2, java environment variable settings-after the JDK is installed on the computer in the detailed version (JDK 1.7 is used here, And the JDK is installed in other versions), the Java environment will take effect. First, right-click my computer. Open properties. Then select "environment variables" in "advanced". On the newly opened interface, you need to set three system variable attributes: "java_home", "path", and "classpath ". Before JDK is installed, the path attribute originally exists, while the java_home and classpath system variables do not exist and need to be created. Click "new" and write java_home in "variable name (n)". The java_home variable indicates the installation path of Java. Then, write "C: \ jdk1.7" in the just-installed path in the variable value (n ". (Note: If the installation path is not disk C or is not in the jdk1.7 folder, you can modify it accordingly. The following text is assumed to be installed in c: \ jdk1.7 .) Second, find the path in the system variable and click "edit". the PATH variable indicates that the system can recognize Java commands in any path. Then write ".; % java_home % \ bin "(" % java_home % "indicates the value of java_home just set), you can also directly write" C: \ jdk1.7 \ bin ", the former is recommended for high reusability. Third, click "new" and then write classpath on the variable name. The classpath variable indicates the path of the Java loading class (class or Lib). Only the class in classpath can be identified by Java commands. Then write ".; % java_home % \ Lib \ DT. jar; % java_home % \ Lib \ toos. jar "(to add. indicates the current path.) finally, after setting the Java environment variables, press "OK" until the attribute window disappears. That is, the settings of the Java environment variables are successfully saved and verified. Open "start"> "run", and press "cmd" to go To the DOS system interface. Enter "Java-version" if the installation is successful. The system displays Java version JDK "1.7.0 ". In this way, the Java environment variable settings are OK! Summary: Java environment variable setting purpose: 1. java_home (1) for reference convenience. For example, your JDK is installed in the c: \ Program Files \ Java \ jdk1.7.0 directory, set java_home to the directory path. To use this path later, you only need to enter % java_home % to avoid entering a long path string for each reference. (2) normalization principle: when your JDK path needs to be changed, you only need to change the variable value of java_home. Otherwise, you need to change any document that uses the absolute path to reference the JDK directory, if a program cannot find the JDK, the program may crash. (3) The third-party software will reference the agreed java_home variable to use the software normally, after using Java for a long time, you will know that if a software cannot be used normally, it may be caused by incorrect java_home settings; 2, classpath is set for the program to find the corresponding ". class "File For example, compile a Java program ---. java,. class file. If Java A is executed in the current directory, the corresponding result will be obtained (provided that the classpath is set ". "). now. when the class is moved to another directory (for example, "E: \") and Java A is executed, Java is thrown. lang. noclassdeffounderror is abnormal because it cannot be found. class file, now you add classpath :".; e: \ "run Java A again, and everything is normal. The Java command is found through classpath. class file! 3. Do you want to use % java_home % \ bin \ Java to execute Java commands at any time? Of course not, so, you can add % java_home % \ bin to the path. In this way, we can use Java to execute commands in any path. (When you enter your code in the Command Prompt window, the operating system will find the corresponding application procedure in the current directory and PATH variable directory and execute it. iii. Java environment variable settings-Incorrect case: Java. lang. noclassdeffounderror Description: When a Java virtual machine or classloader Instance tries to load in the class definition (as part of a common method call or as part of a new instance created using a new expression ), however, this exception is thrown when the definition of this class cannot be found. Cause: the Java environment variable settings are incorrect.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.