From owner-freebsd-java@FreeBSD.ORG Wed Apr 19 13:49:06 2006 Return-Path: X-Original-To: freebsd-java@freebsd.org Delivered-To: freebsd-java@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CC73916A401 for ; Wed, 19 Apr 2006 13:49:06 +0000 (UTC) (envelope-from jbq@anyware-tech.com) Received: from caraldi.com (195-13-58-165.oxyd.net [195.13.58.165]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5408843D46 for ; Wed, 19 Apr 2006 13:49:06 +0000 (GMT) (envelope-from jbq@anyware-tech.com) Received: from vision.anyware (10.21.96-84.rev.gaoland.net [84.96.21.10]) by caraldi.com (Postfix) with ESMTP id 81D3F620C for ; Wed, 19 Apr 2006 15:49:05 +0200 (CEST) Received: by vision.anyware (Postfix, from userid 1021) id EF83F6173; Wed, 19 Apr 2006 15:49:06 +0200 (CEST) Date: Wed, 19 Apr 2006 15:49:06 +0200 From: Jean-Baptiste Quenot To: freebsd-java@freebsd.org Message-ID: <20060419134906.GG35777@vision.anyware> Mail-Followup-To: freebsd-java@freebsd.org References: <20060411180145.GP53974@vision.anyware> <20060411222343.GA55418@arabica.esil.univ-mrs.fr> <20060412180028.GB29790@vision.anyware> <20060415004125.GA57315@arabica.esil.univ-mrs.fr> <20060417102456.GA37686@watt.intra.caraldi.com> <20060417184123.GA23044@misty.eyesbeyond.com> <20060418084857.GA1715@vision.anyware> <20060419004331.GA82761@arabica.esil.univ-mrs.fr> <20060419134041.GF35777@vision.anyware> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="yNb1oOkm5a9FJOVX" Content-Disposition: inline In-Reply-To: <20060419134041.GF35777@vision.anyware> User-Agent: mutt-ng/devel-r581 (FreeBSD) Subject: Re: Getting JAVA_HOME at runtime X-BeenThere: freebsd-java@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting Java to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Apr 2006 13:49:06 -0000 --yNb1oOkm5a9FJOVX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline This one will still be better. -- Jean-Baptiste Quenot aka John Banana Qwerty http://caraldi.com/jbq/ --yNb1oOkm5a9FJOVX Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename=20060419-freebsd-javavm --- javavm.orig Wed Apr 19 15:20:23 2006 +++ javavm Wed Apr 19 15:48:54 2006 @@ -6,6 +6,30 @@ # They can then be selected from based on environment variables and the # configuration file. # +# Environment variables affecting the behaviour of this program: +# +# +# JAVA_HOME +# +# Allows to choose the preferred JVM +# +# +# JAVA_VERSION +# +# Allows to choose a preferred JVM version +# +# +# JAVAVM_PRINT_JAVA_HOME +# +# When set, find the best suitable JVM and print the corresponding value of +# JAVA_HOME instead of executing the java program +# +# +# JAVAVM_PRINT_JAVA_PROGRAM +# +# When set, find the best suitable JVM and print the path of the Java program +# instead of executing it +# # ---------------------------------------------------------------------------- # "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp): # Maxim Sobolev wrote this file. As long as you retain @@ -43,13 +67,23 @@ tryJavaCommand () { # Check for the command being executable and exec it if so. if [ -x "${1}" ]; then - if [ ! -z "${SAVE_PATH}" ]; then - export PATH=${SAVE_PATH} + if [ -z "$JAVAVM_PRINT_JAVA_HOME" -a -z "$JAVAVM_PRINT_JAVA_PROGRAM" ] ; then + if [ ! -z "${SAVE_PATH}" ]; then + export PATH=${SAVE_PATH} + fi + + exec "${@}" + echo "${IAM}: error: couldn't run specified Java command - \"${1}\"" >&2 + exit 1 + else + if [ -n "$JAVAVM_PRINT_JAVA_HOME" ] ; then + echo "${JAVA_HOME}" + else + echo "${@}" + fi + exit 0 fi - exec "${@}" fi - - echo "${IAM}: warning: couldn't run specified Java command - \"${1}\"" >&2 } # --yNb1oOkm5a9FJOVX--