It's not a secret anymore!*
The moose likes Beginning Java and the fly likes [HeadFirstJSPServlets] Having trouble with Classpath issues 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 » Beginning Java
Bookmark "[HeadFirstJSPServlets] Having trouble with Classpath issues" Watch "[HeadFirstJSPServlets] Having trouble with Classpath issues" New topic
Author

[HeadFirstJSPServlets] Having trouble with Classpath issues

Eric Fancis
Greenhorn

Joined: Jun 14, 2011
Posts: 29
Hello,

I am going through chapter 3 of Head First Servlets and JSP.

I cannot get one of my classes to compile.

Here is the error:


I have verified that the servlet-api.jar is in the specified folder on the classpath.

Any ideas?

Thanks!

http://www.h4t3r.com
Anurag Verma
Ranch Hand

Joined: Mar 30, 2012
Posts: 124

I dont discourage you doing compilations the hardcore way, but i recommend using a Java IDE of your choice (Eclipse, IntelliJIdea, Netbeans...there are a lot options). The IDE will take care of the compilation stuff & will make your life easy.
Eric Fancis
Greenhorn

Joined: Jun 14, 2011
Posts: 29
I understand, but I'm trying to get a good grasp on how everything works under the hood. I will use an IDE in the future.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Anurag Verma wrote:I dont discourage you doing compilations the hardcore way, but i recommend using a Java IDE of your choice ...

I disagree. I think learning to do it "the hardcore way" is best at first.

Eric Fanc wrote:I have verified that the servlet-api.jar is in the specified folder on the classpath.

It's not on the classpath. if it were, you would not be getting the error.

You said "folder". For jars, you need to include the jar itself, not the folder it is in.

(Be sure not to copy servlet-api.jar anywhere. Leave it where it is and include it in the classpath in place._


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Eric Fancis
Greenhorn

Joined: Jun 14, 2011
Posts: 29
Bear Bibeault wrote:
Anurag Verma wrote:I dont discourage you doing compilations the hardcore way, but i recommend using a Java IDE of your choice ...

I disagree. I think learning to do it "the hardcore way" is best at first.

Eric Fanc wrote:I have verified that the servlet-api.jar is in the specified folder on the classpath.

It's not on the classpath. if it were, you would not be getting the error.

You said "folder". For jars, you need to include the jar itself, not the folder it is in.

(Be sure not to copy servlet-api.jar anywhere. Leave it where it is and include it in the classpath in place._


I have the jar listed:
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

If you are using Windows, then why are you using ":"? You should be using ";" to separate files in class-path. I am not sure of myself if this is causing the problem. Just try and let me know.

Additionally, you could try one more thing. Set the class path explicitly before attempting to compile your java file as follows:

set classpath= C:\Development\apache-tomcat-7.0.35\lib\servlet-api.jar;<any other classes/jars files separated by ;>

Then fire the javac command. Let me know if this works.


~ Mansukh
Eric Fancis
Greenhorn

Joined: Jun 14, 2011
Posts: 29
Mansukhdeep Thind wrote:If you are using Windows, then why are you using ":"? You should be using ";" to separate files in class-path. I am not sure of myself if this is causing the problem. Just try and let me know.

Additionally, you could try one more thing. Set the class path explicitly before attempting to compile your java file as follows:

set classpath= C:\Development\apache-tomcat-7.0.35\lib\servlet-api.jar;<any other classes/jars files separated by ;>

Then fire the javac command. Let me know if this works.


Very good! I am following a book that uses a Mac for its coding exercises.

So the classpath should be:
?

Thanks!
Mansukhdeep Thind
Ranch Hand

Joined: Jul 27, 2010
Posts: 1157

Did your class compile without errors?
Eric Fancis
Greenhorn

Joined: Jun 14, 2011
Posts: 29
yep! Thank you very much!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: [HeadFirstJSPServlets] Having trouble with Classpath issues
 
Similar Threads
Newbie question: Going through Head First Servlets & JSP book
Javac cannot find servlet package
How To Compile Servlet
Java doesn't know where to find servlet packages
Unable to import