Hi, I'm having a compile problem with javac. I just downloaded J EE 5 SDK from Sun and added it to the CLASSPATH variable, but my servlet will not compile due to package javax.servlet.http does not exist. My classpath is as follows:
At the command prompt I am typing:
C:\java> javac BeeServlet.java
That is all.
Joined: Nov 18, 2008
I look at the FAQ and wasn't able to find anything I have not done. I have the j2ee.jar in the classpath and the import statement is correct, so I'm not sure what the issue is.
Omar Al Kababji
Joined: Jan 13, 2009
As long as you assume that you don't have anythong wrong we can't help. How are we supposed to know the problem if you don't show us how are you doing it? We don't do magics, at least give us some logs.
The Servlet can be compiled the same way as any other Java source file. You can compile
it from the command line using javac, or if you are using an integrated development environment
(IDE), use the IDE’s compile command or menu option. You will need to include the
correct Java EE library for the compilation. There are two possible libraries to choose from,
depending on whether you are using the Java EE reference implementation, the Tomcat server,
or JBoss. It doesn’t matter which one you use. If you have the Java EE SDK, you can use the
javaee.jar library; if you have Tomcat or JBoss (which uses Tomcat), you can use servlet-api.jar. For example, if you’re using the Java EE reference implementation, assuming JAVAEE_HOME
is the environment variable for the location of the Java EE SDK, you could compile the Servlet
with the following command line on Windows systems:
> javac –classpath %JAVAEEHOME%\lib\javaee.jar Login.java On Linux and Unix systems, you would use this command line:
> javac –classpath $JAVAEEHOME/lib/javaee.jar Login.java
If you’re using Tomcat 5, assuming CATALINA_HOME is the location of the Tomcat installation,
on Windows systems, compile the Servlet with the following command:
> javac –classpath %CATALINA_HOME%\common\lib\servlet-api.jar Login.java On Linux and Unix systems, use this command:
> javac –classpath $CATALINA_HOME/common/lib/servlet-api.jar Login.java
Joined: Nov 18, 2008
Guys, I was able to compile my servlet.
What I did was change the Path variable.
Originally it was as follows:
I removed c:\j2sdk1.4.2_05\bin
and added C:\Sun\SDK\jdk\bin
My new Path variables look like this:
This is my classpath which has remained the same:
I am not sure why this works now except that the j2sdk1.4.2_05\bin was not compatible with J EE 5 SDK I downloaded. Am I thinking correctly? Can anyone offer insight?
Joined: Oct 13, 2005
Since Java 1.4.2 was superseded by Java 5 in Autumn 2004, and I think J2EE5 is more recent, that might well be the problem.
subject: Compile problem not finding package javax.servlet.http