Three environment variables that need to be set frequently in Java:
Java_home, classpath, path
(1) Configure environment variables: (relative path)
1.
Java_home = x:/jdk1.6.0
2.
% Java_home % can replace: X:/jdk1.6.0.
Classpath
.: $ Java_home/lib/tools. jar: $ java_home/lib/dt. jar: $ java_home/lib/activation. jar: $ java_home/lib/mail. Jar
Or
Classpath
.; % Java_home %/lib/tools. jar; % java_home %/lib/dt. Jar
3.
Path
; % Java_home %/bin
(2) Configure environment variables: (absolute path)
1.
Java_home
D:/jdk1.5.0
2.
Classpath
.; D:/jdk1.5.0/lib/tools. jar; D:/jdk1.5.0/JRE/lib/RT. jar;
3.
Path
D:/jdk1.5.0/bin;
(3)
Run the following code in batches, which is convenient for setting environment variables.
@ Echo off
If exist % 1/bin/java.exe (
If REM enters the correct java2sdk installation directory, it starts to set environment variables.
@ Setx java_home % 1
@ Setx PATH %; % java_home %/bin
@ Setx classpath % ;.
@ Setx classpath %; % java_home %/lib/tools. Jar
@ Setx classpath %; % java_home %/lib/dt. Jar
@ Setx classpath %; % java_home %/JRE/lib/RT. Jar
@ Echo on
@ Echo Java 2 SDK environment parameters are set and exit normally.
) Else (
If "% 1" = ""(
If the installation directory is not provided by REM, exit after prompt
@ Echo on
@ ECHO does not provide the installation directory of java2sdk, and does not set anything. Now exit the environment variable settings.
) Else (
Rem if non-empty installation directory is provided but no bin/java.exe is available, the specified directory is the wrong directory.
@ Echo on
@ ECHO: the installation directory of the invalid java2sdk is not set. Now exit the environment variable settings.
)
)
(4) Other Practices
CMD command settings
Set Path = C:/j2sdk1.4.0/bin