• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Confusion with environment variables

 
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?

 
Bartender
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.

 
Sony Agrawal
Ranch Hand
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 143
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Posts: 4116
72
Mac TypeScript Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
Marshal
Posts: 79151
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I always thought JAVA_HOME was a way to make altering the PATH easier. Nothing more than that. But I might be mistaken.
 
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic