Bug 39080 - java/javavmwrapper: Functionality enhancement
Summary: java/javavmwrapper: Functionality enhancement
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: Greg Lewis
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-06-10 01:20 UTC by Shelton C. Johnson Jr. <Shelton C. Johnson Jr.
Modified: 2004-11-11 19:19 UTC (History)
0 users

See Also:


Attachments
file.diff (447 bytes, patch)
2002-06-10 01:20 UTC, Shelton C. Johnson Jr. <Shelton C. Johnson Jr.
no flags Details | Diff
javavm-patch.uu (1.97 KB, text/plain)
2002-06-10 01:20 UTC, Shelton C. Johnson Jr. <Shelton C. Johnson Jr.
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Shelton C. Johnson Jr. <Shelton C. Johnson Jr. 2002-06-10 01:20:01 UTC
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'.
Comment 1 Pete Fritchman freebsd_committer freebsd_triage 2002-06-10 02:00:15 UTC
Responsible Changed
From-To: freebsd-ports->sobomax

Over to maintainer.
Comment 2 Mark Linimon freebsd_committer freebsd_triage 2004-05-21 22:35:46 UTC
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?
Comment 3 Greg Lewis freebsd_committer freebsd_triage 2004-06-14 16:06:22 UTC
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). 


Comment 4 Greg Lewis freebsd_committer freebsd_triage 2004-06-14 16:06:22 UTC
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.
Comment 5 Greg Lewis freebsd_committer freebsd_triage 2004-11-11 19:19:15 UTC
State Changed
From-To: open->closed

I've committed an updated javavmwrapper with the desired functionality. 
Thanks for the example code and reviews!