This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

classpath difference?

 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

i have my servlet-api.jar in D:\servlet

if i set this path in environmental variable(only path value..not calsspath)..then the jar file is not recognized(when i try to compile)
..but when i put it into classpath also..its working

for compiling a java file,only path is enough know ?(core java file(not servlet-api.jar))...

please any one can explain me...
thanks & regards,
seetharaman
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your PATH variable is what the system used to find executables (like java and javac). The CLASSPATH variable is used by java and javac to find Java classes.

So, there in no need to put servlet-api.jar on your PATH environment variable.
It does need to be added to your CLASSPATH environment variable in order for javac to find the servlet api classes.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12126
30
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
for compiling a java file,only path is enough know ?

that depends...

the path variable tells your operating system (Windows, Unix, whatever...) where to look for programs you want to run. when you type "javac myClass.java", the OS says "hmmm... i need to find the javac.exe program. it's not in the current directory. let me check all the directories listed in the PATH environment variable (in the order they are listed) and see if i can find it."

that is the ONLY thing the PATH variable is used for. it really has nothing to do with how java works - it's only used to find the executables.

the CLASSPATH variable is used by the java programs to find various class files.

So, depending on what you are doing, you may not need to set either, you may need to set both, or you may need to set only one. although you're almost ALWAYS going to update your PATH to make life easier.
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks a lot ...Ben Souther and fred rosenberger
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic