Java environment variables

Source: Internet
Author: User
First, environment variables are actually a group of variables, just like the variables you defined in Java. They are used for systems and applications. Program Provide parameters. Specific to the details, such as path, which is an important variable in the system, it tells the system and application the storage location of some essential programs in the system, for example, if you want to use the ipconfig command in the command line window to view your IP address, how does the system know where ipconfig is located? The answer is to retrieve each parameter from start to end using the path. For example, if there is a C:/Windows/system32 in the path, blow it and add ipconfig to check whether the program can be found, now it is changed to C:/Windows/system32/ipconfig. If it can be found, it will run. If it cannot be found, "'ipconfig' is not an internal or external command, it is not a running program or batch processing file." For Java, If you input Java XXX in the command line, the system also does not know the location of the Java EXE file. You also need to explicitly point out where is the Java program? In your JDK installation path/bin folder, that is to say, to run Java, path must point to the bin folder. There is another classpath. Now the system can find the Java program. But in this case, if you enter javac in the command line, an error occurs again, some people may say that you didn't say that the system found it through path. Should you be able to find the javac program under the binfile I set? Here, although you have already set the path, but the system still cannot find some things, what? Java class library files, we all know that there is always a lot of Java source code above, such as import Java. XX. XX; statement. This is the referenced Java class library. Someone may ask, my program does not have this sentence, for example, there is no such thing in the classic "helloworld", and there is no explicit reference to it, but the "Import Java. lang. * "; now the problem arises. How can the program find this lang Package and import the classes in it? Obviously, path alone does not work, so we can only define another variable to point to the class library file. It is classpath. Why is this name? No, it specifies that this name must be used. It must be called this name. It can be understood as a static variable defined in Java JDK, you only need to assign a value to it. However, JDK does not have a value when calling it. That is to say, you have not created a classpath and assigned a value to it, so there is no way to give it a look. Another point is that someone may ask what the java_home variable is. In the current stage, this variable is a variable defined by ourselves, which is used to save your effort, for example, your JDK installation path is very deep, for example, to install "C: /program files/Sun/Java/jdk1.6.0 _ 02/"and then you must enter" C: /program files/Sun/Java/jdk1.6.0 _ 02/bin ", set classpath to" C: /program files/Sun/Java // jdk1.6.0 _ 02/lib/tools. jar ", you are tired of the system, and the path and classpath become very long, and the next setting will become very troublesome, it takes half a day to find the place you want to change. Now java_home appears. You can define an environment variable named java_home in the system. Its value is "C: /program files/Sun /Java/jdk1.6.0 _ 02 ", you can directly write it when setting the path, and add" % java_home %/bin "in the path value, which is so simple, the corresponding classpath is: ",; % java_home %/tools. jar "is more concise? In addition, you only need to change the path when you change the installation path or make an error. You do not need to modify the path and classpath at the same time. At this point, I will continue to say a few words, java_home can be capitalized, or even the name can be changed to "sxy", "A", or something else you can think, anyway, you only need to reference it (that is, the system will replace it with the value of the variable when the system sees the variable around %, for example, when the "% java_home %/bin" system above saw this, it changed % java_home % to C:/program files/Sun/Java/jdk1.6.0 _ 02) make sure that the name is the same (Case Insensitive), but if you use tomcat or other software later, it will check your java_home variable, so it is best to keep this name unchanged, but if you don't need it at this stage, you just need it. Now, I understand that some people may say that I am too embarrassed to release an environment variable example: java_home = C:/program files/Java/jdk1.6.0 _ 02 (the variable name is represented before the equal sign, later, I expressed the value. This detailed explanation shows that my IQ is declining ~~ The following figure shows the installation location of your JDK. If your JDK is installed by default in 1.6, you can set it like this. If not, it will be changed accordingly ); add a sentence (!!! Note that if you do not remove the original items, many programs will not be able to run. If you delete them, contact me.) % java_home %/binclasspath = .; % java_home %/lib/tools. jar; in addition, it is best to add the location of the program you write yourself. For example, if your common programs are stored in D:/source, simply add them. Don't forget the semicolon ~~~
 want to know more about environment variables? Click here: http://baike.baidu.com/view/95930.htm 

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.