• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Enviornment Variables,classpath and path

 
Aditya Godbole
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello

can anyone tell me the difference between classpath and path?

also what is an enviornment variable and why we are set environment varibale explicitly?

what is the use of CATELINA_HOME path I know that if we are not set it then error will come but what exactly the meaning of it?

please give me the solution.
[ October 17, 2008: Message edited by: Bear Bibeault ]
 
Muhammad Saifuddin
Ranch Hand
Posts: 1324
Android Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to Javaranch,

I hope this entry in FAQs will definitely helps to understand about classpath..
 
fred rosenberger
lowercase baba
Bartender
Pie
Posts: 12017
24
Chrome Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the PATH environment variable has been around a LONG time. I am pretty sure it pre-dates java. it is basically a list of directories that the operating system (windows, Unix...) uses to search through when you type a command.

it would really suck to have to type

/usr/local/bin/ls

every time you wanted to run the 'ls' command on unix, so the directory "/usr/local/bin" is put in your path. here is what my path looks like on one of our unix boxes:

/CISV1R4/scripts:/CISV1R4/bjc:/CISV1R4/install:/CISV1R4/bin:/usr/java14/bin:/usr/local/bin:/usr/bin:/etc:/usr/sbin:/usr/ucb:/home/cisadm/bin:/usr/bin/X11:/sbin:/home/cisprod/sqllib/java/db2java.zip:/userfiles/med/utils/bin:/CISV1R4/bjc/med/scripts/replayerrors:/usr/java14/jre/sh:/usr/java14/sh:/usr/local/java/bin:.:/home/cistest/sqllib/bin:/home/cistest/sqllib/adm:/home/cistest/sqllib/misc:/usr/java131/jre/sh:/usr/java131/sh:/CISV1R4/bjc/med/utils


Any time i type a command, the OS says "well, let's see if i can find an executable called 'ls' in the "/CISV1R4/scripts" directory. Nope? ok, how about in the "/CISV1R4/bjc" directory. Nope? how about in the..." and it keeps going until it finds it, or runs out of places to look.

so, your OS will use the PATH directory to find where the java executable file is so that can run. This is all done behind the scenes.

now... java needs to find class files to run. When you start the java program, you can explicitly state the location of your classfiles, but that gets old pretty quick. So, they came up with the CLASSPATH variable. java (once it starts) uses the CLASSPATH variable (in the same way the OS uses the PATH variable) to see where to look for you class files. Here is my CLASSPATH on one of our unix boxes:

/usr/WebSphere/AppServer/classes:/usr/WebSphere/AppServer/servlets:/home/cisdev/sqllib/java/db2java.zip:/usr/WebSphere/AppServer/lib:/usr/WebSphere/AppServer/lib/jsdk.jar:/usr/WebSphere/AppServer/lib/ibmwebas.jar:/usr/local/java/lib/classes.zip:/CISV1R4/bjc/classes:/usr/lpp/internet/server_root/java/lib/classes111.zip:/usr/lpp/mqm/java/lib/com.ibm.mq.jar:/usr/lpp/mqm/java/lib/com.ibm.mqjms.jar:/usr/lpp/mqm/java/lib/jms.jar:/usr/lpp/mqm/java/lib/jndi.jar:/usr/lpp/mqm/java/lib/:/usr/lpp/mqm /java/lib/com.ibm.mqbind.jar:/usr/lpp/mqm/java/lib/connector.jar:/home/cisdev/sqllib/samples/java/samples.zip:/usr/WebSphere/AppServer/lib/servlet.jar:/usr/WebSphere/AppServer/lib/ejs.jar:/usr/WebSphere/AppServer/lib/databeans.jar:/usr/WebSphere/AppServer/lib/idb.jar:/usr/WebSphere/AppServer/lib/ujc.jar:/usr/WebSphere/AppServer/lib/rowset.jar:/usr/WebSphere/AppServer/lib/WebJContextor.jar:/home/cistest/sqllib/java/db2java.zip:/home/cistest/sqllib/java/db2jcc.jar:/home/cistest/sqllib/java/sqlj.zi p:/home/cistest/sqllib/function:/home/cistest/sqllib/java/db2jcc_license_cu.jar:.


I don't want to type all those every time i run a java program. so, java knows to search all of those directories each time it is trying to find a class file. Notice the last directory in the list is a dot. That means 'search the current directory as well'. having a dot in your classpath can help solve a lot of issues.

if you are a beginner, I wouldn't worry about setting the classpath just yet. But if you do, make sure you have a dot in there somewhere (and note that the separator between directories varies by OS).
 
Sumit Jindal
Greenhorn
Posts: 3
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Regarding CATALINA_HOME,
If you go through your startup.bat or startup.sh file inside Tomcat/bin folder, you will find they are using this key to refer to the path (which depends on where you installed your tomcat) of the Tomcat folder.
So, you need to mention this path in environmental variables so that the batch file can get the actual path of your tomcat directory.

Thanks
Sumit
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic