It's not a secret anymore!*
The moose likes Tomcat and the fly likes Classpath problem with Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Products » Tomcat
Bookmark "Classpath problem with Tomcat" Watch "Classpath problem with Tomcat" New topic
Author

Classpath problem with Tomcat

J Chitra
Greenhorn

Joined: Sep 16, 2004
Posts: 18
Hi,
I was trying to workout the MVC example in HF S&J chapter 3, I get an error with Tomcat saying that the root cause:

Unable to find a javac compiler;
com.sun.tools.javac.Main is not on the classpath.
Perhaps JAVA_HOME does not point to the JDK

and my path sttings are:
JAVA_HOME:c:\j2sdk1.4.2_06
PATH:%JAVA_HOME%\bin
CLASSPATH:C:\j2sdkee1.3\lib\j2ee.jar;%JAVA_HOME%\bin;
c:\prj\coffee-v1\classes;c:\tomcat\common\lib\servlet-api.jar;

and am working on windows!


SCJP(1.4)
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

are you starting tomcat from a windows service? (tomcat runs when you turn on your computer)...

If so, it does not use the JAVA_HOME variable you've set. You have to manually tweak the registry.
J Chitra
Greenhorn

Joined: Sep 16, 2004
Posts: 18
Thanks Mike!
I am running Tomcat manually. I find the SCWCD forum more appropriate for this and found questions of same sort and i have posted the same topic there.
Thanks again.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

what version of windows, what version of Tomcat?

What do you get when you type:

cd c:\j2sdk1.4.2_06\bin
java -version

finally, though I'm against the advice (because you should be able to get Tomcat working without this).. you could copy tools.jar from your JDK into the common/lib directory of Tomcat. This is noted in the second bullet point on this page
J Chitra
Greenhorn

Joined: Sep 16, 2004
Posts: 18
hi Mike,
Many thanks.
windows:XP,Tomcat:5.0.28
I checked the version of java and it is:
java version "1.4.2_06"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)
Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

I copied the tool.jar to common\lib in tomcat, it works fine now.

by the way, may i know why r u against this?
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

For the same reason I'm against putting anything in the /ext directory. It should be possible to keep tools.jar in *one* place, and have it referenced. That's what JAVA_HOME is supposed to do. As an example of why this is bad: Let's say 8 months from now, you upgrade your JDK. Let's say that there are incompatibilities. Are you going to remember that 8 months ago, you copied tools.jar into common/lib?
J Chitra
Greenhorn

Joined: Sep 16, 2004
Posts: 18
Gotcha!
 
GeeCON Prague 2014
 
subject: Classpath problem with Tomcat