permaculture playing cards*
The moose likes Beginning Java and the fly likes classpath difference? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "classpath difference?" Watch "classpath difference?" New topic
Author

classpath difference?

Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

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

Joined: Dec 11, 2004
Posts: 13410

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.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11172
    
  16

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.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

thanks a lot ...Ben Souther and fred rosenberger
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: classpath difference?
 
Similar Threads
Compler Errors
problem with using javac -d ?
package javax.servlet.http does not exist
classpath
Problem in setting up Classpath variable in Win ME