File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes Confusion with environment variables Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Confusion with environment variables" Watch "Confusion with environment variables" New topic
Author

Confusion with environment variables

Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
Hi all, I am confused with the environment variables... here is what i have....
1. I am able run the command Java and javac from any directory of my system.
2. i have only set one thing i.e , PATH variable ,to jdk\bin
3. I have NOT set JAVA_HOME.

So what is the actual use of JAVA_HOME ?.I mean to ask... like classpath is set to identify the class files, so is JAVA_HOME is set to identify the java,javac commands?? . If thats the case then even without setting JAVA_HOME how am i able to execute the java and javac commands (Is windows helping me in this case?)


Similarly its the case with the TOMCAT(i understand this is not the right place for tomcat question but still ),
I have used the exe of tomcat. I have not set catalina_home path. I am able to use the tomcat.
Why do we need catalina_home path?

Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

sony agrwal wrote:So what is the actual use of JAVA_HOME ?.I mean to ask... like classpath is set to identify the class files, so is JAVA_HOME is set to identify the java,javac commands?? . If thats the case then even without setting JAVA_HOME how am i able to execute the java and javac commands (Is windows helping me in this case?)

JAVA_HOME is to identify the location of Java and it's class libraries, Application servers like Jboss required to set JAVA_HOME. For Java to work you need only to set the PATH to bin dir of the JDK.

Similarly its the case with the TOMCAT(i understand this is not the right place for tomcat question but still ),
I have used the exe of tomcat. I have not set catalina_home path. I am able to use the tomcat.
Why do we need catalina_home path?

It's required to run the Tomcat. If you try to run it from somewhere else without directly from the bin dir of the Tomcat it will ask you to set the CATALINA_HOME.


SCJP 5 | SCWCD 5
[How to ask questions] [Twitter]
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
Vijitha Kumara wrote:
It's required to run the Tomcat. If you try to run it from somewhere else without directly from the bin dir of the Tomcat it will ask you to set the CATALINA_HOME.

I did not understand this...
Actuall to start tomact i run the file tomcat6.exe present in the tomcat\bin .
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
Vijitha Kumara wrote:For Java to work you need only to set the PATH to bin dir of the JDK.

so you mean to say that i can replace path=jdk\bin to JAVA_HOME=jdk\bin ??
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

sony agrwal wrote:.. Actuall to start tomact i run the file tomcat6.exe present in the tomcat\bin .

Did you install it as a service using tomcat6.exe?
so you mean to say that i can replace path=jdk\bin to JAVA_HOME=jdk\bin ??

Nope. JAVA_HOME is to point to the JDK top directory. You need PATH only to use Java from command line (to compile/execute etc..).
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
Did you install it as a service using tomcat6.exe?

I just downloaded the exe file from tomcat' site and installed it. When i was trying to find out how to start the tomcat i noticed the tomcat6.exe in bin dir on double clicking it... it will start tomcat !!
I do that ecery time when i need to start tomcat.
am I doing the right way(i guess not)
Sony Agrawal
Ranch Hand

Joined: Oct 04, 2009
Posts: 143
Nope. JAVA_HOME is to point to the JDK top directory. You need PATH only to use Java from command line (to compile/execute etc..).

Do you mean to say that if i use some IDE , then the IDE would set the JAVA_HOME to the correct dir and use it???
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

sony agrwal wrote:
Did you install it as a service using tomcat6.exe?

I just downloaded the exe file from tomcat' site and installed it. When i was trying to find out how to start the tomcat i noticed the tomcat6.exe in bin dir on double clicking it... it will start tomcat !!
I do that ecery time when i need to start tomcat.

Ok, then no problem, That's because the installer asks you the location of the JRE so you don't need to set JAVA_HOME or anything explicitly.
Vijitha Kumara
Bartender

Joined: Mar 24, 2008
Posts: 3859

sony agrwal wrote:
Nope. JAVA_HOME is to point to the JDK top directory. You need PATH only to use Java from command line (to compile/execute etc..).

Do you mean to say that if i use some IDE , then the IDE would set the JAVA_HOME to the correct dir and use it???

IDEs (like eclipse) normally ask you (or you can configure) which Java version to use.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
I always thought JAVA_HOME was a way to make altering the PATH easier. Nothing more than that. But I might be mistaken.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Confusion with environment variables