Javavmwrapper provides a convenient mechanism to support multiple JVMs on one system and invoke them through a common script named javavm. This limits it to running only the core 'java' executable from the JVM. Many packages need access to other utilities provided with the JDK such as javac, jar, rmic etc. Through the creation of additional symbolic links in $PREFIX/bin which correspond to those in $JAVA_HOME/bin, this tool can be extended to allow access to those additonal utilities. For example /usr/local/jdk1.3.1/bin contains 44 different executables which are actually symbolic links to the same .java_wrapper script. This patch will extend the functionality of javavmwrapper to include all of the above executables. This patch also sets JAVA_HOME to match the chosen JVM just before launching the utility. This patch does not update the packing list for the port to reflect the additional links created when a JVM is registered through registervm. Fix: Apply the following patch. Provided both as a unified diff and a uuencoded version of the same. cvs diff: Diffing javavmwrapper cvs diff: Diffing javavmwrapper/src +# Compute $JAVA_HOME/bin from $JAVA_HOME/bin/java (aka $1) +# Look for $IAM in that directory +# If it is present, run it with JAVA_HOME set appropriately and all other args +# If this fails fall back to the old logic. This shouldn't happen. tryrunVM () { - if [ -x "${1}" ]; then + Jbin=`dirname "${1}"` + JAVA_HOME=`dirname $Jbin` + export JAVA_HOME + if [ -x "${Jbin}/${IAM}" ]; then + shift + exec "${Jbin}/${IAM}" ${@} + elif [ -x "${1}" ]; then exec "${@}" fi @@ -43,8 +53,22 @@ VM=`/bin/echo "${1}" | sed 's|#.*||'` if [ ! -x ${VM} ]; then - /bin/echo "${IAM}: warning: the specified JavaVM \"${VM}\" either not e xists or not executable" >&2 + /bin/echo "${IAM}: warning: the specified JavaVM \"${VM}\" either does not exist or is not executable" >&2 fi + # Locate all symbolic links in the $JAVA_HOME/bin directory for the + # new JVM. If they don't already exist in $PREFIX/bin, create symbolic + # links for them to javavm in $PREFIX/bin. This lets tools like jar, + # appletviewer, rmic all work as expected. + cd $PREFIX/bin + Jbin=`dirname "${1}"` + for i in $Jbin/* + do + Jtool=`basename $i` + if [ -h $i -a ! -e $PREFIX/bin/$Jtool ] + then + ln -s javavm $Jtool + fi + done /bin/ed "${CONF}" >/dev/null <<EOF 0a How-To-Repeat: Just use javavm. Unless you explicitly add /usr/local/jdk1.3.1/bin to your path you will be unable to invoke java, javac, jar or other standard tools. The javavm script will only invoke java and is not very transparent to scripts and other tools looking for 'java'.
Responsible Changed From-To: freebsd-ports->sobomax Over to maintainer.
State Changed From-To: open->feedback Has there been any progress on this PR? With all the recent changes in bsd.java.mk, it is still even germane?
State Changed From-To: feedback->open The PR is still relevant since it deals with running java after installation rather than the port builds (which are what bsd.java.mk is for).
Responsible Changed From-To: sobomax->glewis I've taken PR 27079 which is also about javavmwrapper, so it makes sense to take this one too.
State Changed From-To: open->closed I've committed an updated javavmwrapper with the desired functionality. Thanks for the example code and reviews!