• Post Reply Bookmark Topic Watch Topic
  • New Topic

JAVA_HOME Environmental Variable  RSS feed

 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

This question is not related to Java code specifically, but rather the installation of a Java application on a Windows machine. We intend to distribute one of our applications on a CD, allowing users to install it via a simple installer which makes use of a bunch of batch files. The installation process installs Java, MySQL and Glassfish, after which it deploys our server app in Glassfish and copies our client app to a folder on the user's machine and creates a desktop shortcut. However, if JAVA_HOME is not set, the Glassfish installation is not completed succesfully and nothing works properly from there onwards.

Has anyone ever tried something similiar? Our users won't be particularly tech-savvy, and therefore we would like to set JAVA_HOME programmatically (from a batch file). If we set it in a batch file though, it is only temporary, so as soon as it's needed in another (3rd party) batch file, it's gone.

Any help will be much appreciated. Thanks!

Regards,
Riaan
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anyone?
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, plenty of batch files set JAVA_HOME. I'm not sure why you're asking -- just do it. On most platforms environment variables are really intended to be a temporary way of communicating between specific processes; the whole control-panel/global environment thing is a Windows abomination, anyway. Set it in your batch file, and be done with it.

It's quite possible, by the way, to set it only if it isn't already set, or to set it based on the physical location of the script. See the batch files that come with Tomcat for excellent examples of both of these tricks.
 
Riaan Nel
Ranch Hand
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ernest Friedman-Hill wrote:Yes, plenty of batch files set JAVA_HOME. I'm not sure why you're asking -- just do it. On most platforms environment variables are really intended to be a temporary way of communicating between specific processes; the whole control-panel/global environment thing is a Windows abomination, anyway. Set it in your batch file, and be done with it.

It's quite possible, by the way, to set it only if it isn't already set, or to set it based on the physical location of the script. See the batch files that come with Tomcat for excellent examples of both of these tricks.


Hi Ernest

Thank you for your reply. I've tried setting JAVA_HOME in a batch, but the problem is that it is 'too' temporary. As soon as the batch file is done executing, JAVA_HOME goes back to not having a value, or it's old value. (On Windows Server 2003, at least). When another batch file tries to make use of the variable, it's just not there anymore. I'll check out the Tomcat scripts though, thanks for the tip.

By the way, awesome pictures on drawspace.com!

Regards,
Riaan
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!