Link to home
Start Free TrialLog in
Avatar of Valeri
ValeriFlag for Bulgaria

asked on

JAVA_HOME in Tomcat...?!?!?!

I installed Tomcat on my computer, and I'm trying to run one jsp, but I'm getting this error :

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

I have assigned JAVA_HOME to : C:\j2sdk1.4.2_03, I tried with C:\j2sdk1.4.2_03\bin also, but the result is the same!
It's the first time when I use Tomcat, so I thing that the problem is not so big, but I can't get over it, because I'm not so familiar with this stuff.

Thanks in advance!
Best regards,
Valeri
Avatar of rrz
rrz
Flag of United States of America image

>I installed Tomcat on my computer  
So, you can browse to Tomcat's home page using  http://localhost:8080/      ?
Can run the servlet and JSP examples on that page  ?
>I have assigned JAVA_HOME to : C:\j2sdk1.4.2_03
That should work, but show us the actual line in your Autoexec.bat  .
Avatar of Valeri

ASKER

Yes, I'm able to see Tomcat home page, it works perfectly, and examples that come with Tomcat installation also work perfectly, but as I see the .class files are with old date, in my opinion this means that they are not compiled now.
The newly added .jsp's doesn't work?!?! I don't know way?
Thanks in advance,
Valeri


Check out this kink..

http://www.coreservlets.com/Apache-Tomcat-Tutorial/

Hope this Helps!!
>I have assigned JAVA_HOME to : C:\j2sdk1.4.2_03,  
Please show us the line in your Autoexec.bat
Avatar of Valeri

ASKER

Hi again,
I have assigned JAVA_HOME using "Control Panel / System / Environment Variables". As I know that's way to do that. Am I wrong? My Autoexec.bat is empty.
The standart Tomcat Welcome page works fine, after that I tried very simple .html page and it also works, but when I rename this simple .html page to .jsp page I get this error! Except initializing JAVA_HOME variable, is there anything else that I have to do?
Thanks in advance.
Valeri
Avatar of expertmb
expertmb

>I have assigned JAVA_HOME to : C:\j2sdk1.4.2_03

check the variable value for JAVA_HOME
if you have for example "C:\j2sdk1.4.0_03;"
then remove the ";"

mb...


>I have assigned JAVA_HOME to : C:\j2sdk1.4.2_03

check the variable value for JAVA_HOME
if you have for example "C:\j2sdk1.4.0_03;"
then remove the ";"

mb...


Avatar of Valeri

ASKER

I don't have ";" at the end of the line.
Have you created your CLASSPATH variable?
e.g.
JAVA_HOME is C:\j2sdk1.4.2_03
J2EE_HOME is C:\j2sdkee1.4
Classpath is .;%J2EE_HOME%\lib\j2ee.jar;%JAVA_HOME%\lib\tools.jar;%JAVA_HOME%\jre\lib\charsets.jar
Avatar of Valeri

ASKER

I found out something very interesting. When I go to "install_dir/bin" and start the Tomcat by "catalina run" the server starts and everything goes ok, but when I start it by "Monitor Tomcat / Start service" the JSP's don't work!
What is wrong and where is the difference?
Best regards,
Valeri
>My Autoexec.bat is empty.
You could try editing it directly by right clicking on the file itself and choosing "edit".
Mine looks like this  

SET PATH=C:\WINDOWS;C:\WINDOWS\COMMAND;C:\j2sdk1.4.2_04\BIN
SET JAVA_HOME=C:\j2sdk1.4.2_04
SET CATALINA_HOME=C:\jakarta-tomcat-5.0.25
SET CLASSPATH=.;C:\jakarta-tomcat-5.0.25\common\lib\servlet-api.JAR


>but when I start it by "Monitor Tomcat / Start service" the JSP's don't work!  
I don't know this. What is your OS ?
Avatar of Valeri

ASKER

Windows 2000
Avatar of Valeri

ASKER

So, may be the main question is : How do you start the Tomcat??? By going to Tomcat\bin directory and typing "catalina run" or by starting the service by "Strat Menu/Programs/Apache Tomcat 5.0/Monitor Tomcat" and after that 'Start service' ? My be the secong approach is just wrong, I don't know?!?!
So, how do you start Tomcat? Because by typing "catalina run" everithing is ok!

Best regards,
Valeri
> How do you start the Tomcat???    
I just double click on  Tomcat\bin\startup.bat    
Avatar of Valeri

ASKER

This causes "catalina start", it is similar like "catalina run" as I can see. And it's open CMD window, isn't it?
>And it's open CMD window, isn't it?  
I don't know what you asking.
I just followed instructions in the documentation. See  RUNNING.txt  in Tomcat's root folder.
ASKER CERTIFIED SOLUTION
Avatar of ss_p
ss_p

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Valeri

ASKER

Yes,
When I start Tomcat by double click startup.bat then everithing is OK.
I just tried to start it from "Start service" item from the right click on the icon that appears next to the clock, at the right-bottom corner. What this service is designed for?
Valeri,

Apache tomcat services (jk_nt_services) use JAVA_HOME information that you configured when you install tomcat.

if you set a wrong path, there're only 2 way for you.
- run Tomcat\bin\startup.bat by yourself
- Install tomcat again and don't miss it

As one of our friend mentioned

1. we should have the PATH, JAVA_HOME, CATALINA_HOME & CLASSPATH environment variables set properly.
also you can add necessary jar files in the CLASSPATH variable

SET CLASSPATH=.;C:\jakarta-tomcat-5.0.25\common\lib\servlet-api.jar;%CLASSPATH%

2. where is your jsp files are placed?

Eeither you can use the defaule examples application or you can configure your own application by creating a folder under
        %CATALINA_HOME%\webapps, ie.. %CATALINA_HOME%\webapps\myapp
     This 'myapp' folder should have
     1. WEB-INF folder, inside this folder copy/create web.xml , 'lib' folder and 'classes' folder
             -classes folder will have the custom classes and packages
             -lib folder will have the necessary jar files
     2. jsp files can be under the new application folder ie.. %CATALINA_HOME%\webapps\myapp or a new subfoler can be created %CATALINA_HOME%\webapps\myapp\myjsps and
        used.