From owner-freebsd-java@FreeBSD.ORG Wed Apr 19 15:45:46 2006 Return-Path: X-Original-To: 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 EA54516A487; Wed, 19 Apr 2006 15:45:45 +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 428C343D5A; Wed, 19 Apr 2006 15:45:41 +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 71816620C; Wed, 19 Apr 2006 17:45:40 +0200 (CEST) Received: by vision.anyware (Postfix, from userid 1021) id 1B3686173; Wed, 19 Apr 2006 17:45:42 +0200 (CEST) To: FreeBSD-gnats-submit@freebsd.org From: Jean-Baptiste Quenot X-send-pr-version: 3.113 X-GNATS-Notify: Message-Id: <20060419154542.1B3686173@vision.anyware> Date: Wed, 19 Apr 2006 17:45:42 +0200 (CEST) Cc: java@freebsd.org Subject: Allow java/javavmwrapper to report the location of the JVM 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 15:45:46 -0000 >Submitter-Id: current-users >Originator: Jean-Baptiste Quenot >Confidential: no >Synopsis: Allow java/javavmwrapper to report the location of the JVM >Severity: non-critical >Priority: medium >Category: ports >Class: update >Release: FreeBSD 5.5-PRERELEASE i386 >Environment: System: FreeBSD vision.anyware 5.5-PRERELEASE FreeBSD 5.5-PRERELEASE #1: Thu Mar 9 19:20:53 CET 2006 jbq@vision.anyware:/usr/obj/usr/src/sys/VISION i386 >Description: Please see discussion at http://lists.freebsd.org/pipermail/freebsd-java/2006-April/005152.html The Java ports infrastructure provides ${JAVA_HOME} and ${JAVA} on build-time to a port's Makefile, but it would be great to set the Java version requirement on a per-port basis in the rc flags. This requires to get JAVA_HOME and java executable path from javavmwrapper at runtime. The idea is to make javavm recognize two special environment variables: 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 For this to work correctly, we need javavm to stop upon failure. Until now, when the java program cannot be exec-uted, javavm issues a warning and goes on to the next JVM. Thanks in advance! >Fix: diff -ru javavmwrapper.orig/src/javavm.1 javavmwrapper/src/javavm.1 --- javavmwrapper.orig/src/javavm.1 Tue Apr 19 00:03:27 2005 +++ javavmwrapper/src/javavm.1 Wed Apr 19 17:32:22 2006 @@ -124,6 +124,12 @@ .Ql 1.5 and .Ql 1.5+ . +.It Ev 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. +.It Ev JAVAVM_PRINT_JAVA_PROGRAM +When set, find the best suitable JVM and print the path of the Java program +instead of executing it. .El .Sh FILES .Bl -tag -width indent diff -ru javavmwrapper.orig/src/javavmwrapper.sh javavmwrapper/src/javavmwrapper.sh --- javavmwrapper.orig/src/javavmwrapper.sh Fri Nov 4 00:04:40 2005 +++ javavmwrapper/src/javavmwrapper.sh Wed Apr 19 17:29:22 2006 @@ -6,6 +6,8 @@ # They can then be selected from based on environment variables and the # configuration file. # +# Please have a look at the javavm(1) man page for more information. +# # ---------------------------------------------------------------------------- # "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp): # Maxim Sobolev wrote this file. As long as you retain @@ -43,13 +45,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 } #