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 Path and classpath  required Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Path and classpath  required" Watch "Path and classpath  required" New topic

Path and classpath required

sweety mehra

Joined: Feb 09, 2007
Posts: 9
to run java program, what complete path and classpath to be set as an enivronment variable.
Also tell me ,what value should be set for JAVA_home and why JAVA_HOME is needed
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 237
JAVA_HOME must point to your java install directory and you should also include %JAVA_HOME%/bin in your path (Because you have the executables in the bin directory).Classpath refers to dependencies,that will depend on the application.

Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15083

You do not need to set any environment variables to be able to run Java programs.

You can add the bin directory of the Java Runtime Environment (JRE) or Java Development Kit (JDK) to the PATH if you want - this is only for convenience, so that you don't have to type the whole path every time.

You do not need to set CLASSPATH. If you need the JRE to look for classes in other places than the directory from where you start your program, then you can set the classpath on the command line with the "-cp" (or "-classpath") option.

The variable JAVA_HOME is not used at all by the JRE or JDK. Some programs use this to find your Java installation (Apache Tomcat for example), but Java itself does not need it.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 237

That was very helpful.It weeded out certain misconceptions.

I agree. Here's the link:
subject: Path and classpath required
It's not a secret anymore!