This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes problem in saving a servlet prog.. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "problem in saving a servlet prog.." Watch "problem in saving a servlet prog.." New topic
Author

problem in saving a servlet prog..

venkatesh badrinathan
Ranch Hand

Joined: Aug 03, 2008
Posts: 77
hi everybody, i am new to servlets. i have installed j2ee5.0 sdk in my system and tried to compile a helloworld servlet program. i do not know where to save my program in the sdk directory. i have tried it saving in bin directory but my program gave err saying, "javax.servlet package does not exist".
once i get a class file, i know how to deploy my servlet.
please tell me the exact path to save my program so that i could compile it.


SCJP1.5
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
You can keep your source code wherever you want to. It does not need to be in the SDK directory, and I would advise NOT to keep it there.

In order to compile servlets, you need to have the jar file containing the servlet API in your classpath. You can do this by compiling like this:

javac -classpath C:/path/to/jee/sdk/servlet-api.jar MyServlet.java


Ping & DNS - my free Android networking tools app
venkatesh badrinathan
Ranch Hand

Joined: Aug 03, 2008
Posts: 77
Thanks ulf, but i did not find servlet-ai.jar file in my system.
i have all the setup files that i have mentioned below.
j2eesdk-1_4_03-windows
j2eesdk-1_4_03-windows-ml
java_ee_sdk-5_05-windows
let me uninstall the old setups then.
please let me know which of them should i install so that i can go ahead with servlets.
thanks in advance..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
Go with the JEE 5 installer; JEE 5 is a newer version than J2EE 1.4.

The jar file may be named something else. Just look through the jar files that get installed. One of them has the classes you need.
venkatesh badrinathan
Ranch Hand

Joined: Aug 03, 2008
Posts: 77
am sorry. i have spent most of the time to find out that jar file to compile my servlet, but could not figure it out. also tried saving the prog everywhere the in directory, but nothing worked out.. is there any other way please..
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41141
    
  45
As I said, the directory where you save your source code doesn't matter. But it's better NOT to mix it up with the SDK itself.
The classpath determines where the compiler looks for missing classes. See this tutorial for more detail on that.

Which jar files did you find? Post the names, and we may be able to point out the one you're missing. You can also use the "jar tf" option of the "jar" command to look into jar files (and thus learn which classes they contain).
 
Consider Paul's rocket mass heater.
 
subject: problem in saving a servlet prog..
 
Similar Threads
How to test servlets?
Cannot run program from another directory other than c:\Sun\SDK\jdk\bin
Compiling problem - CLASSPATH is the issue
Where is my file?
file name