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 error in the source file 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 "error in the source file" Watch "error in the source file" New topic
Author

error in the source file

sahana mithra
Ranch Hand

Joined: Oct 26, 2010
Posts: 72
I tried a servlet program where i placed the .java file in bin and in the source. I tried compiling both. It shows error in import javax.servlet, http methods. What is the reason for these errors?
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

What do the errors say? What do you mean by this:

where i placed the .java file in bin




JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
Not sure what you mean by "bin", but it doesn't sound like the right place for source files. How are you adding the jar file that contains the javax.servlet and javax.servlet.http packages to the classpath?
sahana mithra
Ranch Hand

Joined: Oct 26, 2010
Posts: 72
I tried to create class file first in src inside webapps/.../src/Helloworld.java and then tried keeping the source file inside bin I also tried keeping the source file inside d: setting home,path and class path. Please let me know the correct procedure.
sahana mithra
Ranch Hand

Joined: Oct 26, 2010
Posts: 72
which package should i add i mean which jar file should i add other than servlet-api.jar and where should i add it?
Lester Burnham
Rancher

Joined: Oct 14, 2008
Posts: 1337
It doesn't matter where the source files are, but whatever "bin" is (I can't tell from your post), it sounds like a place for binaries, not source code.

For compiling servlets you don't need anything else but servlet-api.jar in the classpath. You can achieve that by compiling somewhat like this:

javac -cp "c:\this\is\the\path\to\servlet-api.jar" MyServlet.java

This assumes that the .java file is in the current directory, and that there are no complications arising from packages. If there are, then this may help: http://download.oracle.com/javase/tutorial/java/package/managingfiles.html
sahana mithra
Ranch Hand

Joined: Oct 26, 2010
Posts: 72
hi all,
Thanks for your effort. I just found out the silly mistake which i did with setting home and classpath. Its working fine now.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: error in the source file
 
Similar Threads
Loading and instantiating a remote class?
Unix With Java....
How to modify classpath ?
How to run Servlet program on Eclipse.?
Cant compile my java files on DOS