aspose file tools*
The moose likes Java in General and the fly likes PATH, JAVA_HOME and JRE_HOME best practices Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "PATH, JAVA_HOME and JRE_HOME best practices " Watch "PATH, JAVA_HOME and JRE_HOME best practices " New topic
Author

PATH, JAVA_HOME and JRE_HOME best practices

Jim Smithian
Greenhorn

Joined: Sep 21, 2004
Posts: 18
Java applications usually start by batch files or shell scripts which among other things set the executable java from the JRE_HOME or JAVA_HOME or the PATH environment variables. What are the best practices in writing such scripts and setting the PATH and JRE_HOME and JAVA_HOME considering the following factors:

-security
-convenience for average end users
-multiple versions of JRE/JDK in the same machine

Should we find 'java' from the PATH, JRE_HOME or JAVA_HOME?

Is there any good online resources about these?

Thanks for your comments.

Jim
Stevi Deter
Ranch Hand

Joined: Mar 22, 2008
Posts: 265

Jim,

Good question. We usually use JAVA_HOME.

More important than what you pick is that you document it in an easy way for your users to find out and know what to set if they haven't already!


There will always be people who are ahead of the curve, and people who are behind the curve. But knowledge moves the curve. --Bill James
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19720
    
  20

JAVA_HOME should be set to the home folder of your JDK - typically C:\jdk1.6.0_05 (or whatever version and wherever you installed it).

JRE_HOME is hardly ever needed - I've never ever set it before.

PATH should include "%JAVA_HOME%\bin" for Windows or $JAVA_HOME/bin for Linux / Unix / ...
Depending on whether or not JAVA_HOME contains any spaces you'd want to put the entire path, including the \bin, in quotes.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: PATH, JAVA_HOME and JRE_HOME best practices