File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes how to set java env variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to set java env variables" Watch "how to set java env variables" New topic

how to set java env variables

nancy andrew
Ranch Hand

Joined: Jan 19, 2010
Posts: 30
Hi all,

Please let me know what will be the value of PATH, CLASSPATH and JAVA_HOME in environment variables.

Currently i have set:

PATH = C:\Program Files\Java\jdk1.5.0_09\bin;
JAVA_HOME = C:\Program Files\Java\jdk1.5.0_09;

I remember that somethin is set uptill C:\Program Files\Java\jdk1.5.0_09\lib\tools.jar;

I dont know what is that. Kindly tell me what will be the classpath and where to set tools.jar
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11957

I don't think we can answer all that. Environment variables are custom to your own setup. However...

Most folks here would recommend beginners DON'T set a CLASSPATH variable at all. It should not exist.

Your PATH should have lots of directories in it, most likely. Mine looks like this:

C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Program Files\Common Files\Lenovo;C:\Program Files\Lenovo\Client Security Solution;c:\Program Files\Altiris\Software Virtualization Agent\;C:\Novell\GroupWise;C:\Program Files\Common Files\Ulead Systems\MPEG;C:\strawberry\c\bin;C:\strawberry\perl\site\bin;C:\strawberry\perl\bin;C:\Program Files\Java\jdk1.6.0_23\bin;C:/Python27

it contains the directories for programs you frequently run.

And I don't have a 'java_home' set on my machine.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15100

tools.jar does not need to be added to any environment variable.

PATH is for the operating system, so that it knows where to find executables such as the Java compiler (javac.exe) and other tools that are in the bin directory of the JDK.

CLASSPATH is for Java, it contains the directories and JAR files that it should search for *.class files. You normally do not need to set this.

JAVA_HOME is not necessary for Java. Some programs use this to find the directory where the JDK is installed, but unless you have a program that needs this, you do not need to set it.

So the only thing you really need to do is add the bin directory of the JDK to your PATH variable, but you already seem to have done this.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: how to set java env variables
jQuery in Action, 3rd edition