Difference among JAVA_HOME,JRE_HOME,CLASSPATH and PATH
posted 12 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Hi Team,
What are the differences among JAVA_HOME,JRE_HOME,CLASSPATH and PATH ?
Thanks in Advance.
What are the differences among JAVA_HOME,JRE_HOME,CLASSPATH and PATH ?
Thanks in Advance.
posted 12 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
- JAVA_HOME: must point to installation directory of JDK.
- JRE_HOME: must point to installation directory of JRE.
- CLASSPATH: contains libraries path which JVM will look for.
- PATH: normal environment variable on Windows.
- JRE_HOME: must point to installation directory of JRE.
- CLASSPATH: contains libraries path which JVM will look for.
- PATH: normal environment variable on Windows.
posted 12 years ago
-
1 -
-
Number of slices to send:Optional 'thank-you' note:
-
-
JAVA_HOME and JRE_HOME are not used by Java itself. Some third-party programs (for example Apache Tomcat) expect one of these environment variables to be set to the installation directory of the JDK or JRE. If you are not using software that requires them, you do not need to set JAVA_HOME and JRE_HOME.
CLASSPATH is an environment variable which contains a list of directories and / or JAR files, which Java will look through when it searches for Java classes to load. You do not normally need to set the CLASSPATH environment variable. Instead of using this environment variable, you can use the -cp or -classpath option on the command line when using the javac and java commands.
PATH is an environment variable used by the operating system (Windows, Mac OS X, Linux) where it will look for native executable programs to run. You should add the bin subdirectory of your JDK installation directory to the PATH, so that you can use the javac and java commands and other JDK tools in a command prompt window. The JDK installation instructions explain how to set PATH.
CLASSPATH is an environment variable which contains a list of directories and / or JAR files, which Java will look through when it searches for Java classes to load. You do not normally need to set the CLASSPATH environment variable. Instead of using this environment variable, you can use the -cp or -classpath option on the command line when using the javac and java commands.
PATH is an environment variable used by the operating system (Windows, Mac OS X, Linux) where it will look for native executable programs to run. You should add the bin subdirectory of your JDK installation directory to the PATH, so that you can use the javac and java commands and other JDK tools in a command prompt window. The JDK installation instructions explain how to set PATH.
nagul samy
Ranch Hand
Posts: 37
posted 12 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks Team. How does it related to CATALINA_HOME when installing tomcat server, And while I was setting JAVA_HOME path initially I did set "C:\Program Files\Java\jdk1.6.0_37\bin" but it dint work then I replaced it with "C:\Program Files\Java\jdk1.6.0_37" and it's worked! What exactly "/bin" directory has and why PATH is set to bin?
posted 12 years ago
"Catalina" is a code name for Tomcat. The Tomcat startup and shutdown scripts use CATALINA_HOME to determine where Tomcat is installed.
Because JAVA_HOME should be set to the JDK installation directory, and not the bin subdirectory of the JDK installation directory - setting it to C:\...\bin is wrong.
The bin subdirectory contains the executables of the Java compiler and other tools that are part of the JDK (javac.exe, java.exe, jar.exe etc.). The operating system needs to know where these executables are in order to be able to run them.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
nagul samy wrote:How does it related to CATALINA_HOME when installing tomcat server,
"Catalina" is a code name for Tomcat. The Tomcat startup and shutdown scripts use CATALINA_HOME to determine where Tomcat is installed.
nagul samy wrote:And while I was setting JAVA_HOME path initially I did set "C:\Program Files\Java\jdk1.6.0_37\bin" but it dint work then I replaced it with "C:\Program Files\Java\jdk1.6.0_37" and it's worked!
Because JAVA_HOME should be set to the JDK installation directory, and not the bin subdirectory of the JDK installation directory - setting it to C:\...\bin is wrong.
nagul samy wrote:What exactly "/bin" directory has and why PATH is set to bin?
The bin subdirectory contains the executables of the Java compiler and other tools that are part of the JDK (javac.exe, java.exe, jar.exe etc.). The operating system needs to know where these executables are in order to be able to run them.
nagul samy
Ranch Hand
Posts: 37
posted 12 years ago
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Thanks Jesper. Could you please explain how can we access a java file without setting CLASSPATH environment variable and by using -cp or -classpath ?
posted 12 years ago
Even without -cp or -classpath??? it's impossible.
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
nagul samy wrote:Thanks Jesper. Could you please explain how can we access a java file without setting CLASSPATH environment variable and by using -cp or -classpath ?
Even without -cp or -classpath??? it's impossible.
posted 12 years ago
You just specify the classpath on the command line after the -cp or -classpath option, exactly like you would do when you'd set the CLASSPATH.
For example, instead of:
set CLASSPATH=C:\Projects\MyProject\build
java org.mypackage.HelloWorld
you would do:
java -cp C:\Projects\MyProject\build org.mypackage.HelloWorld
Reference: Java application launcher documentation
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
nagul samy wrote:Thanks Jesper. Could you please explain how can we access a java file without setting CLASSPATH environment variable and by using -cp or -classpath ?
You just specify the classpath on the command line after the -cp or -classpath option, exactly like you would do when you'd set the CLASSPATH.
For example, instead of:
set CLASSPATH=C:\Projects\MyProject\build
java org.mypackage.HelloWorld
you would do:
java -cp C:\Projects\MyProject\build org.mypackage.HelloWorld
Reference: Java application launcher documentation
| Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad: Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |











