File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes JAVA_HOME environment variable? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "JAVA_HOME environment variable?" Watch "JAVA_HOME environment variable?" New topic

JAVA_HOME environment variable?

Aniruddha Bhagwat

Joined: Sep 02, 2004
Posts: 3
Hi folks
Now, I am kind of semi-new to Java programming (did manage to write a few programs some time back). But my problem is SOOO basic, it oughta be in this forum.
I was trying out my hand on Win XP on the J2EE SDK 1.4, as i needed to do some servlet/JSP programming. I downloaded it from Sun (about a 100 MB), installed it nicely such that my installation is in

The installation is such that the directory hierarchy is:
C:\Sun\AppServer\ and then it has the various folders like jdk, bin, lib etc. etc.

Now I managed to compile a few java programs, so the PATH env. variable is set correctly (PATH = C:\Sun\AppServer\jdk\bin)
I now downloaded Jakarta Tomcat version 5.0.28, and installed it in C:\jakarta-5.0.28\
I was able to compile a java program that used the tomcat packages, so the CLASS_PATH variable is also set correctly.(CLASS_PATH = C:\jakarta-tomcat-5.0.28\common\lib\servlet-api.jar)
But my problem occurs when I try to run the startup.bat file in
to launch the tomcat server. It says that the JAVA_HOME variable hasn't been set correctly, and that Windows cannot find '-Djava.endorsed.dirs='.
Now, I googled for it all over, and everywhere it says that the JAVA_HOME variable ought to be whee the jdk is installed, so I set it to
but it still doesn't work.
ANy pointers please?
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, Aniruddha!


You might need to set CATALINA_HOME to point to your Tomcat installation.

I think your problem is specific to Tomcat, so I'm moving this to the Tomcat forum...

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Dirk Schreckmann

Joined: Dec 10, 2001
Posts: 7023
Did setting the CATALINA_HOME value do the trick?

If not, I'd suggest a quick search on this forum for phrases such as "java.endorsed.dirs" and "Perhaps JAVA_HOME does not point to the JDK".

Any luck, yet?
Roel De Nijs

Joined: Jul 19, 2004
Posts: 7059

JAVA_HOME must point to that dir where there is a directory called bin and in this directory you can find all *.exe files (like java.exe, javac.exe,...)

so if these files are in c:\temp\blah_blah\bin\ the java_home has to be set to c:\temp\blah_blah

so you have to add to your catalina.bat-file

SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
Aniruddha Bhagwat

Joined: Sep 02, 2004
Posts: 3
Hi all
Thanks for your suggestions - I added JAVA_HOME to catalina.bat, but stillno luck.

Out of frustration, I uninstalled J2EE, and installed J2SE - don't know why I did that, just thought it might work - but still no luck.
Then I had a brainstorm - earlier I had set up a new environment variable for my OWN user, and this time, I set JAVA_HOME as a system variable.

Worked like a charm.
*sniff* Wish technology was easier in the dog days of your life.

SO, MORAL OF THE STORY: Set JAVA_HOME as C:/blah/blah/jdk in your SYSTEM VARIABLES, not user variables!!!
Thanks all anyway. Shall hear from me more often, now that I have atleast started here

P.S: Say, where exactly is the Tomcat forum on the Big Moose Saloon page - can't seem to find it at all - have to come through the link you provided on the Java(beginner) thread.
Aniruddha Bhagwat

Joined: Sep 02, 2004
Posts: 3
OK, mea culpa, found the Apache/TOMCAT forum in the Products sub menu.
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

As an aside.. the reason you needed JAVA_HOME in the system variables (on Windows) is most likely because you installed Tomcat as a system Service.
I agree. Here's the link:
subject: JAVA_HOME environment variable?
It's not a secret anymore!