Wednesday, February 1, 2012

How to Set Classpath for Java on Windows Unix and Linux

In Last Post We Have'seen "How To Set Path For Java in Different Environments".Here is A Post On Setting Class Path.Before Going Into it . First What is ClassPath? Already We Set Path ? is'nt Sufficient ? What's The difference Between Path and Class Path.


 PATH: is a system variable used to tel to OS all locations of exec files. 
CLASSPATH: Is Pure java variable, which is used to tel locations of all jar/zip(classes) files to Compiler.It is Used To Locate User Defined Classes.It Tells  the Java compiler and the Java runtime where to find compiled classes.
For Ex: If We Want To Use Java Database Connectivity Drivers Or Servlets etc We Need To Specify This.


Setting Up Java Class Path in Windows :


1.Right Click My Computer-->Properties

2.Click on Advanced System Settings

3.Click on User Variables

4.Click New And Now Specify The Your environment variable CLASSPATH and put the value of your JAVA_HOME\lib 

5.Save it.

6.We Are Done.

Setting Up CLASSPATH In Linux:


In Linux you can Do This Simply By typing CLASSPATH="your classpath" in Terminal. 


Here Select The Path from either your .bash_profile or .bashrc script which will run whenever you login into your Linux or Unix Machine.

No comments:

Post a Comment