• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Setting classpath

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Sheriff
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This thread may be helpful to you...

https://coderanch.com/t/396453/java/java/javac-classpath-option-answer
 
Raju Bhosla
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 7023
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic