File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes problem getting started Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem getting started" Watch "problem getting started" New topic

problem getting started

J Chandler
Ranch Hand

Joined: May 17, 2003
Posts: 32

I just wrote my first servlet but the compiler can't find the supporting J2EE 1.4 API....
It doesn't recognize any of the Servlet classes i.e. HttpServletRequest, HttpServletResponse, ServletException....

I have downloaded the J2EE1.4 bundle and set environmental variables, but I'm obviously pointing the vm down the wrong path.
Does anyone know the name of the target folder that contains the additional api code?

I already had J2sdk1.4 - the path to this is assigned to JAVA_HOME

Do I substitute this with the new path?
Can I have both, taking into consideration that the J2EE bundle also contains another copy of jdk?

Do I set the path to go to the bin directory of the server: C:\Sun\AppServer\bin
set the path to the bin directory of the jdk within the J2EE bundle?

I'm extremely confused

Regards, J
Vijayendra V Rao
Ranch Hand

Joined: Jul 04, 2004
Posts: 195
Just get the servlet.jar file and add it in your classpath.

Vijayendra <br /> <br />"The harder you train in peace, the lesser you bleed in war"
Ken Robinson
Ranch Hand

Joined: Dec 23, 2003
Posts: 101
If you have the J2EE 1.4 bundle you should have a file called j2ee.jar in your %J2EE_HOME%\lib\ directory. Put j2ee.jar in your classpath when compiling and you'll be fine. You do not need to distribute this in your web app/ejb app when you deploy since the server you will be running on will have it's own implementation of these classes.
J Chandler
Ranch Hand

Joined: May 17, 2003
Posts: 32

hi, thanks for your comments...

I have located j2ee.jar at: C:\Sun\AppServer\lib\j2ee.jar

Put j2ee.jar in your classpath when compiling and you'll be fine.

Do you mean : cd C:\Sun\AppServer\lib
C:\Sun\AppServer\lib> javac //j2ee.jar somewhere around here?
If so, how will the compiler find my .java file?

Also, I still don't know which path to set for JAVA_HOME - leave it pointing to j2sdk1.4, or redirect?
If it's the latter, should I redirect to j2ee.jar?

[ August 04, 2004: Message edited by: J Chandler ]
Jeroen Wenting
Ranch Hand

Joined: Oct 12, 2000
Posts: 5093
read up on the differences between path and classpath and what the compiler and JVM do with each of them.
Only when you understand that you should even start thinking of doing anything involving J2EE.

J Chandler
Ranch Hand

Joined: May 17, 2003
Posts: 32
Good point, well put.

Occasionally, one just needs to be grasped by the shoulders and pointed in the right direction Jeroen...

I agree. Here's the link:
subject: problem getting started
It's not a secret anymore!