This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problem in setting CLASSPATH

 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have set an environmental variable CLASSPATH which has the value .;C:\Java\jdk5.0\lib\dt.jar;C:\Java\jdk5.0\lib\tools.jar;C:\Java\jdk5.0\lib\servlet-api.jar;C:\Java\jdk5.0\lib\jsp-api.jar

Now I am trying to compile a servlet like:

> javac -classpath E:\ABC\classes XYZServlet.java

In this case I am getting error that package javax.servlet.* not found

And if I do not spcify the -classpath option then I got error:
package com.exampe.model not found

where my servlet has the foolowing line:
import com.example.model.*;

Thus, only one classpath is read.
How to use both the packages?
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't worry, the command line does not override your CLASSPATH setting. What is under E:\ABC\classes ? Your java files ? With your command line, I expect to see something like E:\ABC\classes\com\example\model. Are your source files there ?

Another thing, is this a typo ? "package com.exampe.model not found". The "l" in example is missing.
 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was a typing mistake only(in this post)...

If command line does not override the CLASSPATH setting, then why it is the case that I am getting "package javax.servlet not found" when I am specifying -classpath option in the command line and I am getting "package com.example.model not found" instead of "package javax.servlet not found" when I am not specifying the -classpath option.

I have put my .java(helper classes, not servlets) files in E:\ABC\src\com\example\model and my .class files for these .java files are in E:\ABC\classes\com\example\model
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oops, apologizes. It will override your environment variable. You'll have to use one or the other. Look at this FAQ, and set the current directory "." in the CLASSPATH too. Then compile from the root of your source directory.
 
Pranav Pal
Ranch Hand
Posts: 74
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply, Christophe
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic