Java environment settings (for all beginners)

Source: Internet
Author: User

I. Why:

Java environment setting is the first step in learning Java.ArticleIt is very complicated, but there are actually three:

1. Specify the Java executable file path in the environment variable path;
2. Specify the library file (jar package) path required for the Java execution file in the environment variable classpath (the jar package name should be specified );
3. to shorten the length of the path written in the path and classpath, A java_home variable is usually added and referenced with % java_home % during use.

The first reason is thatCodeCompilation and execution are all based on the files/bin in the installation directory. After setting the file in the environment variable path, it can be called in any directory;
The second step is to run Java and the library file is required. Java will find the file specified in the environment variable classpath.

2. How to set it?

The key to other variables is classpath:
First, you must setProgramThe directory, that is.;Otherwise, the class not found error occurs;
Next, point to Rt. jar.
The complete classpath is:
C:/program files/Java/j2re1.4.2/lib/RT. Jar;.

Iii. Differences between setting environment variables in Linux and Windows:

1> set windows in "My Computer", "property", "advanced", and "environment variables"; Set Linux in the ETC/profile file, and add export after setting, after saving the file, run [root @ mypc] # source etc/profile
 
2> when multiple environment variables are set;And:Separated.
 

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.