SET UP THE PATH:Windows 2000/XP:--> set their path by right-clicking on 'My Computer' and selecting 'Properties'. Under the 'Advanced' tab, there is a button that allows you to set the 'Environment variables'. Click on this and alter the 'Path' variable so that it also contains the path to the Java executable. For example, if you have installed Java in c:\jdk and your path is currently set to C:\WINDOWS\SYSTEM32, then you would change your path to read C:\WINDOWS\SYSTEM32;c:\jdk\bin When you open a new command prompt, it will reflect these changes and allow you to run java programs by typing "java". If you have installed the SDK, then you will also be able to run "javac" to compile stuff.
SET UP THE CLASSPATH: In addition to setting up the path, you also need to tell Java where to find compiled class files at runtime. You will probably want to set the classpath to include at least the current working directory (.) Eg: SET CLASSPATH=%CLASSPATH%;. The classpath can also contain other directories that may contain compiled class files. Note that if you are using classes that are contained inside a .jar file, you will need to specify the full path and name of this file in the classpath, rather than just the name of the directory it is contained within.
classpath: .;%java_home%\bin;
java_home: E:\jdk1.3
Path: %java_home%\bin;
When you open a new command prompt, it will reflect these changes and allow you to run java programs by typing "java". If you have installed the SDK, then you will also be able to run "javac" to compile stuff.
In addition to setting up the path, you also need to tell Java where to find compiled
class files at runtime. You will probably want to set the classpath to include at least the current working directory (.) Eg: SET CLASSPATH=%CLASSPATH%;. The classpath can also contain other directories that may contain compiled class files. Note that if you are using classes that are contained inside a .jar file, you will need to specify the full path and name of this file in the classpath, rather than just the name of the directory it is contained within.
变量名 变量值
path C:\j2sdk1.4.1_07\bin
java_home C:\j2sdk1.4.1_07
classpath C:\j2sdk1.4.1_07\lib\tools.jar;C:\j2sdk1.4.1_07\jre\lib\rt.jar;
注意 你 的 版本 号!!(安装于默认目录下)
在Ant 里也可以临时配置的。
^Q^