How to configure jdk1.5 environment variables and run JAVA programs Java_home and so __java
Source: Internet
Author: User
For Beginners Java, the first challenge 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, installation is easy, but the configuration is not so simple, because it wants us to configure environment variables for it.
Here, let me show you how to configure it:
1. Right click on "My Computer", click "Properties": Select the "Advanced" tab, click "Environment variables":
2. In system variables, set 3 system variables, Java_home,path,classpath (note: System variables are useful for all users, and "User variables" are only useful for current login users.) For the case of a variable, it is not differentiated. )
3. Because it is the default installation, JDK1.5 is installed in C:/Program files/java/jdk1.5.0. Now set a value for three variables;
New Java_home Set Value C:/Program files/java/jdk1.5.0
New CLASSPATH set value.; %java_home%/lib;%java_home%/lib/tools.jar
Edit PATH set value;%java_home%/bin;%java_home%/jre/bin
Precautions:
Configure the role of Java_home variables: The java_home path includes folders such as Lib,bin,jre, and then JAVA development software, such as tomcat,eclipse, may need to rely on this variable.
In setting the system variable path (which the system already has), be aware of the semicolon ";" above, and configure the path's role: path enables the system to recognize Java commands under any path.
When setting the system variable Classpath, be aware of the preceding ".;", and configure the role of the CLASSPATH variable: to indicate the path to the Java load class (class or Lib) for the system, only the class is in Classpath, the Java command can recognize it, where% Java_home% is a reference to the Java_home specified earlier.
User variable settings must be logged off before it works, but when all environment variables in this configuration are system variables, the system variables are not used.
4. Test whether the JDK1.5 environment variable is configured successfully.
"Start"-> "Run", type "cmd" into the command prompt, type the command "Java-version", and the following information appears stating that the environment variable configuration was successful:
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 to test whether the JDK1.5 can run the Java program successfully.
Now we're going to edit a Java applet and then we'll test it. Now let's build a "Hello.java" file directly in C, and Notepad to open it and enter the following code inside it:
public class Hello
{public static void main (string[] args)
{System.out.println ("Hello world!");}
}
and then save.
Now go to the command prompt. Input cd/back and forth to the C-packing directory. The following style:
c:/> Java
The program is not run directly, so we have to compile it in advance, that is, the input Javac Hello.java is as follows:
C:/>javac Hello.java
C:/>
This compiles well, and it prompts for errors if it is not compiled properly. Once the Java file is compiled, a class is automatically generated, so we can run it as long as you type "Java Hello".
C:/>java Hello
Hello world! Results.
In this way, we have successfully configured the JDK.
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.