aspose file tools*
The moose likes Beginning Java and the fly likes javac is not recognized when trying to compile a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "javac is not recognized when trying to compile a servlet" Watch "javac is not recognized when trying to compile a servlet" New topic
Author

javac is not recognized when trying to compile a servlet

Ollie Smith
Greenhorn

Joined: Oct 14, 2010
Posts: 4
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

Joined: Jan 10, 2002
Posts: 60975
    
  65

As this has nothing to do with Tomcat, I've moved it to the Beginning Java forum.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60975
    
  65

Have you installed the JDK on the system? Tomcat only needs a JRE to run.
Ollie Smith
Greenhorn

Joined: Oct 14, 2010
Posts: 4
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

Joined: Oct 27, 2005
Posts: 19670
    
  18

Have you modified the PATH variable to include the JDK bin folder?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Ollie Smith
Greenhorn

Joined: Oct 14, 2010
Posts: 4
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

Joined: Nov 24, 2005
Posts: 14687
    
  16

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 ?


[My Blog]
All roads lead to JavaRanch
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38334
    
  23
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

Joined: Oct 14, 2010
Posts: 4
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

Joined: Oct 13, 2005
Posts: 38334
    
  23
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: javac is not recognized when trying to compile a servlet