quality@glassfish.java.net

Re: glassfish plugin 1.11 with Eclipse 3.4 nojdk error

From: Ludovic Champenois <Ludovic.Champenois_at_Sun.COM>
Date: Tue, 14 Oct 2008 11:10:32 -0700

Survivant 00 wrote:
> :)
>
> bon..merci ca marche pour GF et Eclipse. il faudrait peut-etre mettre
> la doc à jour :
> https://glassfishplugins.dev.java.net/specifications/introduction.html
>
> être sur de spécifier que Eclipse doit partir avec un JDK et montrer
> comment.
Or we might able to fix that and follows the GF rules for detected a JDK
when running via Eclipse as well.


attached mail follows:



Here is the order of precedence for JDKs when starting a domain via the Launcher (i.e. asadmin start-domain)

  1. Domain.xml  (java-home inside java-config)
  2. asenv
  3. JAVA_HOME  environmental variable
  4. System.getProperty("java.home") + "../"
  5. System.getProperty("java.home")
  6. 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@glassfish.dev.java.net
For additional commands, e-mail: dev-help@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@glassfish.dev.java.net For additional commands, e-mail: dev-help@glassfish.dev.java.net