Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

javac is not recognized when trying to compile a servlet

 
Ollie Smith
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I've only just passed my SCJP6 and now trying to study for SCWCD, Im currenlty working through the HeadFirst book Servlets & JSP, but and a big but, I have followed the instructions on installing Tomcat and have done with no problems I can start Tomcat and view HTML pages no problem but when I try and compile a servlet I'm getting the message saying 'javac' is not recognized as an internal or external.........(you know the rest)

The page I'm stuck on is pg 81 Compiling, deploying, and testing the controller servlet (if anyone has this book)

The page displays the following:-

cd MyProject/BeerV1
javac -classpath /Users/bert/Applications/tomcat/common/lib/servlet-api.jar:classes:. -d classes src/com/example/web/BeerSelect.java

Please can some one give me some pointers, I'm loosing the will to live and slowing dieing inside.
Thanks
Ollie
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As this has nothing to do with Tomcat, I've moved it to the Beginning Java forum.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64990
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you installed the JDK on the system? Tomcat only needs a JRE to run.
 
Ollie Smith
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers Bear for moving this, I wasn't sure which area to submit this in.
I have got the JDK installed as I have used this previously with other simple programs such as jcreater.

I have set system variables but may not have done this correctly.

Any other pointers?
 
Rob Spoor
Sheriff
Pie
Posts: 20555
57
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you modified the PATH variable to include the JDK bin folder?
 
Ollie Smith
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob,
Is that the CLASSPATH in the system variables, I have done this.
Also I have just typed in the command set PATH=.............. at the cmd then tried javac but still getting the same message.

 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have just typed in the command set PATH=..............

Don't use ...... Which command did you exactly typed ? And in which folder is your jdk ?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Not only "what did you use as your PATH?" but also "what did you use as a CLASSPATH?" You can do no end of harm by setting a system CLASSPATH. Don't. If there is nothing in the system CLASSPATH which you haven't set yourself, delete it altogether. If there is anything in the system CLASSPATH which you didn't set yourself, add .; (on Windows) to the beginning of the CLASSPATH string.
 
Ollie Smith
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Cheers for the Welcome,

In the cmd I entered the following:-
set PATH=c:\Program Files\Java\jdk1.6.0_18\bin;%PATH%

also in the System Variable I enter this as my CLASSPATH:-
C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar

This I know is wrong but still unsure what to do.
I can say now I passed my SCJP but fundamentals section was my lowest area.
 
Campbell Ritchie
Sheriff
Pie
Posts: 49466
64
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Delete that system classpath. Your PATH looks probably correct, assuming you installed Java™ in its default location. Since it has spaces in, you might need to enclose the PATH variable in "" quotes.

Try compiling with the -cp tag. You can find details of the tag for the "java" tool and for the "javac" tool on the net. I think you would have to use -cp .;C:\Program Files\Apache Software Foundation\Tomcat 5.0\common\lib\servlet-api.jar but I am not certain.
When you deploy your files as a .jar you would include those .jars in the classpath in the manifest file.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic