From owner-freebsd-java@FreeBSD.ORG Sat Apr 15 00:41:27 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 B12FB16A407 for ; Sat, 15 Apr 2006 00:41:27 +0000 (UTC) (envelope-from herve.quiroz@esil.univ-mrs.fr) Received: from arabica.esil.univ-mrs.fr (arabica.esil.univ-mrs.fr [139.124.41.108]) by mx1.FreeBSD.org (Postfix) with ESMTP id 146AC43D45 for ; Sat, 15 Apr 2006 00:41:26 +0000 (GMT) (envelope-from herve.quiroz@esil.univ-mrs.fr) Received: from arabica.esil.univ-mrs.fr (localhost [127.0.0.1]) by arabica.esil.univ-mrs.fr (8.13.4/8.13.4) with ESMTP id k3F0fPFX059331 for ; Sat, 15 Apr 2006 02:41:25 +0200 (CEST) (envelope-from herve.quiroz@esil.univ-mrs.fr) Received: (from rv@localhost) by arabica.esil.univ-mrs.fr (8.13.4/8.13.4/Submit) id k3F0fPlv059330 for java@freebsd.org; Sat, 15 Apr 2006 02:41:25 +0200 (CEST) (envelope-from herve.quiroz@esil.univ-mrs.fr) X-Authentication-Warning: arabica.esil.univ-mrs.fr: rv set sender to herve.quiroz@esil.univ-mrs.fr using -f Date: Sat, 15 Apr 2006 02:41:25 +0200 From: Herve Quiroz To: java@freebsd.org Message-ID: <20060415004125.GA57315@arabica.esil.univ-mrs.fr> Mail-Followup-To: java@freebsd.org References: <20060411180145.GP53974@vision.anyware> <20060411222343.GA55418@arabica.esil.univ-mrs.fr> <20060412180028.GB29790@vision.anyware> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20060412180028.GB29790@vision.anyware> User-Agent: Mutt/1.4.2.1i Cc: 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: Sat, 15 Apr 2006 00:41:27 -0000 On Wed, Apr 12, 2006 at 08:00:28PM +0200, Jean-Baptiste Quenot wrote: > > So indeed, JAVA_HOME is set accordingly to the JVM picked up by the > > script. > > > > That's how the launcher shell script works for devel/maven2 for example. > > OK, but imagine that the target application has a shell script > that needs JAVA_HOME. There are plenty of programs that are based > on JAVA_HOME instead of the java binary. > > How to get the preferred JAVA_HOME? ATM you can't. So far, each time I needed such feature I found a workaround or ended up enforcing a JDK in the shell script. Depending on the script you have in mind, such feature could indeed be interesting to implement. The main problem I see here is that javavm cannot tell which JVM is the good one until it manages to run one. So the only way to be sure of our JAVA_HOME would be to run a Java class that uses System.getEnv() to display JAVA_HOME to the standard output. This would just double the startup time of the application. Anyway, if this JAVA_HOME is important to determine, and when dealing with a "server" application which is run once in a while (e.g. at boot), I can imagine it could be worth it. Herve