error finding package when compiling

I�m getting an error because my compiler can�t find J2EE on my machine. I�ve installed the J2EE API (at least I think I have) and I�ve checked my variables �CLASSPATH� and �PATH� to make sure that they are pointed to the right directories.

Here�s all the pertinent info:

I keep getting a compilation error when trying to import J2EE classes. For example:

will cause the compiler to give me a �package javax.servlet.http does not exist� error.

I am using Windows XP, a text editor, and the command line to compile my code. I did have IBM�s WebSphere Application Developer (WSAD)IDE running on this computer at one point, but that is uninstalled now. I also have a DB2 client app running on the computer (it�s noted in the CLASSPATH string below).

CLASSPATH string (I separated each part of the string into a new line for readability):

PATH string:

This shouldn�t be too hard, but apparently it is. Does anyone have any idea why?

Where is the jar that contains the javax.servlet.http.* classes? in the sun/AppServer directories? You need to find which jar file contains them and include that jar file (not just the directory where its located) in your classpath.

Chris Staten

Ranch Hand

Posts: 101

posted 13 years ago

OK, I have a fundamental misunderstanding of the environmental variables on a computer with regards to java packages. After reading Tom�s post I used the following command to successfully compile my code:

I then updated my PATH and CLASSPATH variables to include the following:

Then I unsuccessfully tried to use the following command to compile my code:

There are two questions that I have about this:

Do I always have to give the full path to a jar file that I want to use as opposed to just giving the path to that directory?

Why will my code compile when I use the �classpath argument, but not when I rely on the CLASSPATH variable (therefore leaving off the �classpath argument when compiling)?

-Thanks

EDIT: Is there any difference with regards to Microsoft Windows versus Linux/UNIX on any of this? [ March 07, 2005: Message edited by: Chris Staten ]

Tom Katz

Ranch Hand

Posts: 169

posted 13 years ago

Do I always have to give the full path to a jar file that I want to use as opposed to just giving the path to that directory?

Not sure about this, but I think so... If you have a classes directory (not jarred up) then the directory is sufficient.

Why will my code compile when I use the �classpath argument, but not when I rely on the CLASSPATH variable (therefore leaving off the �classpath argument when compiling)?

Did you open a new dos prompt after changing the CLASSPATH to include the .jar file? A command window won't pick up changes in the environment variables so you need to open a new one. [ March 07, 2005: Message edited by: Tom Katz ]

Chris Staten

Ranch Hand

Posts: 101

posted 13 years ago

Thanks Tom, it WAS because I hadn�t opened a new dos prompt. I ended up having to tweak one more thing to be able to leave off the �classpath argument. I had to append �classes/� to my CLASSPATH environmental variable. This was because I am using custom classes in my program which are under the classes/<path>/<to>/<java classes> directory. This means that the new portion of my CLASSPATH variable looks like this:

This also seems to validate your statement that �If you have a classes directory (not jarred up) then the directory is sufficient.�

Now I just need to figure out how to include my Oracle JDBC driver classes

You�ve been a big help Tom, thanks.

Tom Katz

Ranch Hand

Posts: 169

posted 13 years ago

NO problem, glad to help...

Here's the two I had to append to my CLASSPATH (tho, its been awhile, so I dont know if you'll have to do more) for oracle JDBC drivers:

-classes12.jar; -nlscharset12.jar

Chris Staten

Ranch Hand

Posts: 101

posted 13 years ago

After a bit of work I got the entire thing figured out and working. If anyone is trying to connect to a remote Oracle database using JSP/SERVLET technology in conjunction with Tomcat then you may find this helpful.

But the answer to including my Oracle JDBC drivers was to put them in my web application�s lib directory. [ March 08, 2005: Message edited by: Chris Staten ]