[pkg-java] r5381 - trunk/java-common/wrappers

fourmond at alioth.debian.org fourmond at alioth.debian.org
Sat Jan 12 01:31:43 UTC 2008


Author: fourmond
Date: 2008-01-12 01:31:43 +0000 (Sat, 12 Jan 2008)
New Revision: 5381

Modified:
   trunk/java-common/wrappers/java-wrappers.sh
Log:
[java-wrappers.sh] Export a decent JAVA_HOME, idea taken from #404728

Modified: trunk/java-common/wrappers/java-wrappers.sh
===================================================================
--- trunk/java-common/wrappers/java-wrappers.sh	2008-01-12 00:03:36 UTC (rev 5380)
+++ trunk/java-common/wrappers/java-wrappers.sh	2008-01-12 01:31:43 UTC (rev 5381)
@@ -232,6 +232,13 @@
 	java_warning "No JAVA_CMD set for run_java, falling back to JAVA_CMD = java"
 	JAVA_CMD=java
     fi
+    # We try to conjure up a JAVA_HOME from JAVA_CMD, if the former
+    # is absent. Idea coming from bug #404728.
+    if [ -z "$JAVA_HOME" ]; then
+	full_cmd_path="$(readlink -f `which $JAVA_CMD`)"
+	JAVA_HOME="${full_cmd_path:bin/*}"
+	java_debug "Using JAVA_CMD to find JAVA_HOME = '$JAVA_HOME'"
+    fi
     if [ "$FORCE_CLASSPATH" ]; then
 	java_debug "Using imposed classpath : FORCE_CLASSPATH = '$FORCE_CLASSPATH'";
 	cp="-classpath $FORCE_CLASSPATH";
@@ -240,13 +247,16 @@
     else
 	cp="";
     fi
+    # Exporting JAVA_HOME, I guess it can't hurt much, can it ?
+    export JAVA_HOME
     java_debug "Environment variable CLASSPATH is '$CLASSPATH'"
     java_debug "Runnning $JAVA_CMD $JAVA_ARGS $cp $@"
     exec $JAVA_CMD $JAVA_ARGS $cp "$@"
 }
 
 # Runs a java jar.
-# You don't have to use this function.
+# You don't have to use this function to run a jar, but you might find
+# it useful, though.
 run_jar() {
     if [ "$looked_for_jars" ]; 
 	java_warning "It is most likely useless to use find_jar when running"




More information about the pkg-java-commits mailing list