Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 5 Apr 2005 15:32:05 +0200
From:      Herve Quiroz <hq@FreeBSD.org>
To:        Sam Lawrance <boris@brooknet.com.au>
Cc:        java@FreeBSD.org
Subject:   Re: JDK specific classpaths
Message-ID:  <20050405133205.GA63174@arabica.esil.univ-mrs.fr>
In-Reply-To: <1112706453.750.22.camel@dirk.no.domain>
References:  <1112706453.750.22.camel@dirk.no.domain>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi Sam,

On Tue, Apr 05, 2005 at 11:07:32PM +1000, Sam Lawrance wrote:
> Since you're around, and handling java PRs... hope you don't mind :)
> 
> I'm looking at the NetRexx port right now. In order to work it needs
> sun.tools.javac.* in the classpath. That stuff is located
> in /usr/local/SOME_JDK/lib/tools.jar
> 
> Any suggestions as to how java should be invoked to provide the
> "correct" tools.jar?
> 
> Simplified, but something akin to:
> java -cp $JDK_HOME/lib/tools.jar
> 
> Any suggestions?

I would indeed use the same approach as you explain here.

To detail further, I would use a launcher shell script
'files/netrexx.sh.in':

#!/bin/sh
"%%JAVA%%" -cp "%%JAVA_HOME%%/lib/tools.jar" ...

And in the Makefile:

SUB_FILES=	netrexx.sh
SUB_LIST=	JAVA="${JAVA}" JAVA_HOME="${JAVA_HOME}"

do-install:
	${INSTALL_SCRIPT} ${WRKDIR}/netrexx.sh ${PREFIX}/bin/netrexx


The downside of this approach is that it is not flexible: the end user
cannot switch JDK at runtime. So here is another approach (still using
the same Makefile):

#!/bin/sh
JAVA_HOME="${JAVA_HOME:-"%%JAVA_HOME%%"}"
"${JAVA_HOME}/bin/java" -cp "${JAVA_HOME}/lib/tools.jar" ...


A last approach would be to implement a 'java-home' tool, part of
java/javavmwrapper, that would use the same logic as javavm but to
produce a suitable JAVA_HOME value. Then:

#!/bin/sh
export JAVA_VERSION="%%JAVA_VERSION%%"
JAVA_HOME="${JAVA_HOME:-"`%%LOCALBASE%%/bin/java-home`"}"
"%%LOCALBASE%%/bin/java" -cp "${JAVA_HOME}/lib/tools.jar" ...

NOTE: %%JAVA_VERSION%% is already added automatically to SUB_LIST by
bsd.java.mk, as well as %%LOCALBASE%%.


That said, and until some volunteer starts working on improving
javavmwrapper, I would go with method #2 (overridable JAVA_HOME).

Hope that helps. Anyway, I'm looking forward to your next PR :)

Herve



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20050405133205.GA63174>