⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 javaenvutils.java

📁 Use the links below to download a source distribution of Ant from one of our mirrors. It is good pra
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            // Sun's layout.            jExecutable = findInDir(JAVA_HOME + "/sh", command);        }        if (jExecutable == null) {            jExecutable = findInDir(JAVA_HOME + "/bin", command);        }        if (jExecutable != null) {            return jExecutable.getAbsolutePath();        } else {            // Unfortunately on Windows java.home doesn't always refer            // to the correct location, so we need to fall back to            // assuming java is somewhere on the PATH.            return addExtension(command);        }    }    /**     * Finds an executable that is part of a JDK installation based on     * the java.home system property.     *     * <p>You typically find them in <code>JAVA_HOME/bin</code> if     * <code>JAVA_HOME</code> points to your JDK installation.</p>     * @param command the java executable to find.     * @return the path to the command.     * @since Ant 1.5     */    public static String getJdkExecutable(String command) {        if (IS_NETWARE) {            // Extrapolating from:            // "NetWare may have a "java" in that directory, but 99% of            // the time, you don't want to execute it" -- Jeff Tulley            // <JTULLEY@novell.com>            return command;        }        File jExecutable = null;        if (IS_AIX) {            // On IBM's JDK 1.2 the directory layout is different, 1.3 follows            // Sun's layout.            jExecutable = findInDir(JAVA_HOME + "/../sh", command);        }        if (jExecutable == null) {            jExecutable = findInDir(JAVA_HOME + "/../bin", command);        }        if (jExecutable != null) {            return jExecutable.getAbsolutePath();        } else {            // fall back to JRE bin directory, also catches JDK 1.0 and 1.1            // where java.home points to the root of the JDK and Mac OS X where            // the whole directory layout is different from Sun's            return getJreExecutable(command);        }    }    /**     * Adds a system specific extension to the name of an executable.     *     * @since Ant 1.5     */    private static String addExtension(String command) {        // This is the most common extension case - exe for windows and OS/2,        // nothing for *nix.        return command + (IS_DOS ? ".exe" : "");    }    /**     * Look for an executable in a given directory.     *     * @return null if the executable cannot be found.     */    private static File findInDir(String dirName, String commandName) {        File dir = FILE_UTILS.normalize(dirName);        File executable = null;        if (dir.exists()) {            executable = new File(dir, addExtension(commandName));            if (!executable.exists()) {                executable = null;            }        }        return executable;    }    /**     * demand creation of the package list.     * When you add a new package, add a new test below.     */    private static void buildJrePackages() {        jrePackages = new Vector();        switch(javaVersionNumber) {            case VERSION_1_6:            case VERSION_1_5:                //In Java1.5, the apache stuff moved.                jrePackages.addElement("com.sun.org.apache");                //fall through.            case VERSION_1_4:                if (javaVersionNumber == VERSION_1_4) {                    jrePackages.addElement("org.apache.crimson");                    jrePackages.addElement("org.apache.xalan");                    jrePackages.addElement("org.apache.xml");                    jrePackages.addElement("org.apache.xpath");                }                jrePackages.addElement("org.ietf.jgss");                jrePackages.addElement("org.w3c.dom");                jrePackages.addElement("org.xml.sax");                // fall through            case VERSION_1_3:                jrePackages.addElement("org.omg");                jrePackages.addElement("com.sun.corba");                jrePackages.addElement("com.sun.jndi");                jrePackages.addElement("com.sun.media");                jrePackages.addElement("com.sun.naming");                jrePackages.addElement("com.sun.org.omg");                jrePackages.addElement("com.sun.rmi");                jrePackages.addElement("sunw.io");                jrePackages.addElement("sunw.util");                // fall through            case VERSION_1_2:                jrePackages.addElement("com.sun.java");                jrePackages.addElement("com.sun.image");                // are there any here that we forgot?                // fall through            case VERSION_1_1:            default:                //things like sun.reflection, sun.misc, sun.net                jrePackages.addElement("sun");                jrePackages.addElement("java");                jrePackages.addElement("javax");                break;        }    }    /**     * Testing helper method; kept here for unification of changes.     * @return a list of test classes depending on the java version.     */    public static Vector getJrePackageTestCases() {        Vector tests = new Vector();        tests.addElement("java.lang.Object");        switch(javaVersionNumber) {            case VERSION_1_6:            case VERSION_1_5:                tests.addElement(                    "com.sun.org.apache.xerces.internal.jaxp.datatype.DatatypeFactoryImpl ");                // Fall tru            case VERSION_1_4:                tests.addElement("sun.audio.AudioPlayer");                if (javaVersionNumber == VERSION_1_4) {                    tests.addElement("org.apache.crimson.parser.ContentModel");                    tests.addElement("org.apache.xalan.processor.ProcessorImport");                    tests.addElement("org.apache.xml.utils.URI");                    tests.addElement("org.apache.xpath.XPathFactory");                }                tests.addElement("org.ietf.jgss.Oid");                tests.addElement("org.w3c.dom.Attr");                tests.addElement("org.xml.sax.XMLReader");                // fall through            case VERSION_1_3:                tests.addElement("org.omg.CORBA.Any");                tests.addElement("com.sun.corba.se.internal.corba.AnyImpl");                tests.addElement("com.sun.jndi.ldap.LdapURL");                tests.addElement("com.sun.media.sound.Printer");                tests.addElement("com.sun.naming.internal.VersionHelper");                tests.addElement("com.sun.org.omg.CORBA.Initializer");                tests.addElement("sunw.io.Serializable");                tests.addElement("sunw.util.EventListener");                // fall through            case VERSION_1_2:                tests.addElement("javax.accessibility.Accessible");                tests.addElement("sun.misc.BASE64Encoder");                tests.addElement("com.sun.image.codec.jpeg.JPEGCodec");                // fall through            case VERSION_1_1:            default:                //things like sun.reflection, sun.misc, sun.net                tests.addElement("sun.reflect.SerializationConstructorAccessorImpl");                tests.addElement("sun.net.www.http.HttpClient");                tests.addElement("sun.audio.AudioPlayer");                break;        }        return tests;    }    /**     * get a vector of strings of packages built into     * that platforms runtime jar(s)     * @return list of packages.     */    public static Vector getJrePackages() {        if (jrePackages == null) {            buildJrePackages();        }        return jrePackages;    }    /**     *     * Writes the command into a temporary DCL script and returns the     * corresponding File object.     * It is the job of the caller to delete the file on exit.     * @param cmd the command.     * @return the file containing the command.     * @throws IOException if there is an error writing to the file.     */    public static File createVmsJavaOptionFile(String[] cmd)            throws IOException {        File script = FILE_UTILS.createTempFile("ANT", ".JAVA_OPTS", null, false, true);        PrintWriter out = null;        try {            out = new PrintWriter(new BufferedWriter(new FileWriter(script)));            for (int i = 0; i < cmd.length; i++) {                out.println(cmd[i]);            }        } finally {            FileUtils.close(out);        }        return script;    }    /**     * Return the value of ${java.home}     * @return the java home value.     */    public static String getJavaHome() {        return JAVA_HOME;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -