File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Setting classpath Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of JavaScript Promises Essentials this week in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Setting classpath" Watch "Setting classpath" New topic
Author

Setting classpath

Raju Bhosla
Greenhorn

Joined: May 12, 2004
Posts: 2
I am using windows xp. I am compiling servlet code by using -classpath option on the command line to point to the servlet-api.jar and jsp-api.jar files in the server directory. However, putting these same paths in the CLASSPATH environment variable and not using the -classpath option on the command line fails to compile as the compiler is not seeing the jar files. What am I missing here?
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
It's hard to answer your problem without seeing what your CLASSPATH variable is set to. Please do ECHO %CLASSPATH% at a DOS prompt and post the output here.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Raju!

Be certain that you're spelling CLASSPATH correctly, with all uppercase letters, as the environment variable.

Also, note that, if opened before changing an environment variable, a command prompt or program like Notepad won't "see" the new environment variable value, and it will use the value that was specified when the program was opened. So, just close them and re-open after changing the environment variable value.


[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Bryan Noll
Greenhorn

Joined: Feb 06, 2004
Posts: 26
This thread may be helpful to you...

http://www.coderanch.com/t/396453/java/java/javac-classpath-option-answer
Raju Bhosla
Greenhorn

Joined: May 12, 2004
Posts: 2
Thanks to all for the responses:

Here is a cut and paste from the XP form for setting the system environment variables:
Variable Name: CLASSPATH
Variable Value:
.;"C:\ServletDevel";"C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\jsp-api.jar";"C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar"

This is what I get from ECHO %CLASSPATH%
.;"C:\ServletDevel";"C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\jsp-api.jar";"C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar"

I have tried compiling in a new window after the changes.
All to no avail.

The same classpath above will option -classpath would compile with no problem. Its still a problem.
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
I'm surprised that you're having this problem, as your CLASSPATH setting looks correct to me, assuming that the specified paths are correct, of course.

Do things compile with the following command?

javac -classpath %CLASSPATH% Foo.java

Just for fun, you might want to try putting your needed JARs in a path with no spaces in the name, setting the CLASSPATH accordingly, and see if things compile.

Just as a bit of encouragement, I've never seen a computer system where Java could not be successfully installed with the CLASSPATH environment variable configured and working. So, don't give up. There's likely just some small thing that's configured incorrectly.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting classpath