wood burning stoves 2.0*
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
Author

Path and classpath required

sweety mehra
Greenhorn

Joined: Feb 09, 2007
Posts: 9
hi
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: 185
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.

Regards,
Srikkanth.M
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14156
    
  19

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 7 API documentation
Scala Notes - My blog about Scala
Srikkanth Mohanasundaram
Ranch Hand

Joined: Feb 07, 2007
Posts: 185
Jesper,

That was very helpful.It weeded out certain misconceptions.

Thanks,
Srikkanth.M
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Path and classpath required