• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

classpath difference?  RSS feed

 
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
 
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.
 
lowercase baba
Posts: 12745
51
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
Boost this thread!