Getting JAVA_HOME at runtime

Herve Quiroz herve.quiroz at esil.univ-mrs.fr
Tue Apr 11 22:23:46 UTC 2006


On Tue, Apr 11, 2006 at 08:01:46PM +0200, Jean-Baptiste Quenot wrote:
> The Java ports infrastructure provides JAVA_HOME on build-time to
> port's Makefile.  But is it possible to get this variable from
> /usr/local/bin/java at runtime?
> 
> How to change the Java version for a port at runtime in the rc
> script?  It is possible to set the preferred JDK in
> /usr/local/etc/javavms but then JAVA_HOME still needs to be
> set manually.
> 
> I would like to avoid hard-coding the JAVA_HOME at build time in
> the rc scripts.
> 
> Any idea?

In /usr/local/bin/javavm, line 447:

  export JAVA_HOME
  tryJavaCommand "${JAVA_HOME}/bin/${IAM}" "${@}"

So indeed, JAVA_HOME is set accordingly to the JVM picked up by the
script.

That's how the launcher shell script works for devel/maven2 for example.

Herve


More information about the freebsd-java mailing list