Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

[HeadFirstJSPServlets] Having trouble with Classpath issues

 
Eric Fancis
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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!
 
Anurag Verma
Ranch Hand
Posts: 168
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 65111
89
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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._
 
Eric Fancis
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Eric Fancis
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1158
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did your class compile without errors?
 
Eric Fancis
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
yep! Thank you very much!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic