wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes error finding package when compiling Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "error finding package when compiling" Watch "error finding package when compiling" New topic
Author

error finding package when compiling

Chris Staten
Ranch Hand

Joined: Sep 24, 2004
Posts: 101
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?
Tom Katz
Ranch Hand

Joined: Aug 19, 2002
Posts: 169
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

Joined: Sep 24, 2004
Posts: 101
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

    Joined: Aug 19, 2002
    Posts: 169
    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

    Joined: Sep 24, 2004
    Posts: 101
    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

    Joined: Aug 19, 2002
    Posts: 169
    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

    Joined: Sep 24, 2004
    Posts: 101
    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 ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: error finding package when compiling