• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

[HeadFirstJSPServlets] Having trouble with Classpath issues

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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!
 
Ranch Hand
Posts: 171
Hibernate Spring Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Ranch Hand
Posts: 1164
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1164
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Did your class compile without errors?
 
Eric Fancis
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yep! Thank you very much!
 
reply
    Bookmark Topic Watch Topic
  • New Topic