How to configure jdk1.5 environment variables and run Java program java_home

Source: Internet
Author: User
For beginners of Java, the first difficulty is to configure a Java Development Platform for themselves. However, you have to install software such as JDK. For jdk1.5 installation, I think everyone will, that is, keep clicking, it is easy to install, but the configuration is not that simple, because it requires us to configure environment variables for it.
Here, let me teach you how to configure it:
1. Right-click "my computer" and click "properties": Select the "advanced" tab and click "environment variables ":
2. in "system variables", set three system variables: java_home, path, and classpath (note: "system variables" are useful to all users, the "User variable" is only useful to the current login user. Variables are case insensitive .)
3. jdk1.5 is installed in C:/program files/Java/jdk1.5.0 because it is installed by default. Set values for the three variables;
Create java_home value C:/program files/Java/jdk1.5.0
New classpath value.; % java_home %/LIB; % java_home %/lib/tools. Jar
Edit path settings; % java_home %/bin; % java_home %/JRE/bin
Note:
The function of configuring the java_home variable is as follows: The java_home path contains Lib, bin, JRE, and other folders. Later Java development software such as Tomcat and eclipse may need to depend on this variable.
When setting the system variable path (which is already available in the system), pay attention to the Semicolon ";". Configure path to enable the system to identify Java commands in any path.
When setting the system variable classpath, pay attention to the previous ".; ", configure the classpath variable: Specifies the path of the Java loading class (class or Lib) for the system. Only the class in classpath can be identified by the Java command, % java_home % refers to the previously specified java_home.
The setting of user variables takes effect only after logon is canceled. However, when all environment variables in this configuration are system variables, you do not need to set system variables.
4. test whether the environment variables of jdk1.5 are configured successfully.
"Start"-> "run", type "cmd", enter the command prompt, and type "Java-version". The following information is displayed, indicating that the environment variable is successfully configured:
Java version "1.5.0" Java (TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)
Java hotspot (TM) Client VM (build 1.5.0-b64, mixed mode, sharing)
5. Use a small Program Test whether jdk1.5 can successfully run the Java program.
Now we edit a Java Applet and test it. Now let's create a "hello. Java" file on drive C, open it in notepad, and enter the following in it: Code :
Public class hello
{Public static void main (string [] ARGs)
{System. Out. println ("Hello world! ");}
}
Save the settings.
Now go to the command prompt. Enter CD/to return to the C root directory. That is, the following style:
C:/> JAVA
The program cannot run directly. Therefore, we need to compile it first, that is, input javac hello. Java as follows:
C:/> javac hello. Java
C:/>
In this way, the compilation is completed. If the compilation is not completed, it will prompt an error. After the Java file is compiled, a class compilation file is automatically generated, so we can run it, as long as we enter "Java hello.
C:/> JAVA hello
Hello world! // Result.
In this way, we have successfully configured JDK.

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.