Java JVM getJvmExecutablePath()

Here you can find the source of getJvmExecutablePath()

Description

Get the path of the JVM executable.

License

Open Source License

Return

path to JVM executable

Declaration

public static Object getJvmExecutablePath() 

Method Source Code

//package com.java2s;
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell

import java.io.File;

public class Main {
    /**// ww  w. ja v  a  2  s .  co  m
     * Get the path of the JVM executable.
     * Tries to identify the same JVM executable as the one
     * that is executing currently.  Otherwise, just returns
     * "java".  Note that the full JVM executable path will 
     * (probably) only be found on Linux/Unix for JRE/JDK
     * installations that use the standard directory layout.
     * 
     * @return path to JVM executable
     */
    public static Object getJvmExecutablePath() {
        String javaHome = System.getProperty("java.home");
        File jvmExe = new File(javaHome + "/bin/java");
        if (jvmExe.exists()) {
            return jvmExe.getPath();
        }
        return "java";
    }
}

Related

  1. getJVM()
  2. getJVMClassPath(boolean includeBootClassPath)
  3. getJvmDll(String javahome)
  4. getJVMPath()
  5. isJdk()