dev@glassfish.java.net

Re: How do I switch java during 'asadmin start-domain'

From: Lloyd Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Thu, 09 Oct 2008 08:46:15 -0700

Maybe this is awkward, but it might be friendly to have a log message
emitted something like:

JAVA_HOME=... (from <location>)

On Oct 8, 2008, at 11:50 AM, Byron Nevins wrote:

>
> Here is the order of precedence for JDKs when starting a domain via
> the Launcher (i.e. asadmin start-domain)
>
> Domain.xml (java-home inside java-config)
> asenv
> JAVA_HOME environmental variable
> System.getProperty("java.home") + "../"
> System.getProperty("java.home")
> null (should be impossible -- 4 or 5 must have a vaild JDK or JRE
> or launcher code could not have run!)
> -- Thank You!
>
>
> **** LAUNCHER ****
> private void setJavaExecutable() throws GFLauncherException {
> // first choice is from domain.xml
> if (setJavaExecutableIfValid(javaConfig.getJavaHome()))
> return;
>
> // second choice is from asenv
> if (!
> setJavaExecutableIfValid(asenvProps.get(JAVA_ROOT_PROPERTY)))
> throw new GFLauncherException("nojvm");
>
> }
>
> ***** ASEnv Reader *******
>
> private void setJavaRoot() {
> // make sure we have a folder with java in it!
> // note that we are not in a position to set it from
> domain.xml yet
>
> // first choice -- whatever is in asenv
> String javaRootName =
> props.get(SystemPropertyConstants.JAVA_ROOT_PROPERTY);
>
> if(isValidJavaRoot(javaRootName))
> return; // we are already done!
>
> // try JAVA_HOME
> javaRootName = System.getenv("JAVA_HOME");
>
> if(isValidJavaRoot(javaRootName))
> {
> javaRootName = SmartFile.sanitize(new
> File(javaRootName)).getPath();
> props.put(SystemPropertyConstants.JAVA_ROOT_PROPERTY,
> javaRootName);
> return;
> }
> // try java.home with ../
> // usually java.home is pointing at jre and ".." goes to the
> jdk
> javaRootName = System.getProperty("java.home") + "/..";
>
> if(isValidJavaRoot(javaRootName))
> {
> javaRootName = SmartFile.sanitize(new
> File(javaRootName)).getPath();
> props.put(SystemPropertyConstants.JAVA_ROOT_PROPERTY,
> javaRootName);
> return;
> }
>
> // try java.home as-is
> javaRootName = System.getProperty("java.home");
>
> if(isValidJavaRoot(javaRootName))
> {
> javaRootName = SmartFile.sanitize(new
> File(javaRootName)).getPath();
> props.put(SystemPropertyConstants.JAVA_ROOT_PROPERTY,
> javaRootName);
> return;
> }
>
> // TODO - should this be an Exception? A log message?
> props.put(SystemPropertyConstants.JAVA_ROOT_PROPERTY, null);
> }
>
> private boolean isValidJavaRoot(String javaRootName) {
> if(!GFLauncherUtils.ok(javaRootName))
> return false;
>
> // look for ${javaRootName}/bin/java[.exe]
> File f = new File(javaRootName);
>
> if(GFLauncherUtils.isWindows())
> f = new File(f, "bin/java.exe");
> else
> f = new File(f, "bin/java");
>
> return f.exists();
> }
>
>
>
> Sahoo wrote:
>>
>> In GF v1/v2, we could specify the JDK location in asenv.conf. How
>> do we do it in GFv3?
>>
>> Thanks,
>> Sahoo
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
>> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>>
>
> --
> Byron Nevins Work 408-276-4089, Home 650-359-1290, Cell 650-784-4123
> - Sun Microsystems, Inc.
> --------------------------------------------------------------------- To
> unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net For
> additional commands, e-mail: dev-help_at_glassfish.dev.java.net