JDK specific classpaths
Herve Quiroz
hq at FreeBSD.org
Tue Apr 5 06:32:30 PDT 2005
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
More information about the freebsd-java
mailing list