Determining location of JVM executable during runtime

后端 未结 5 1161
挽巷
挽巷 2020-12-18 19:07

How does one obtain the location of the executable of the currently running JVM during runtime? I would like to instantiate another JVM as a subprocess using the ProcessBuil

5条回答
  •  执笔经年
    2020-12-18 19:57

    Yes, there is a way to get the path of the JVM executable (if it exists). Include it in the configuration of the application. There are lots of ways to do that: Command line argument -- java myApp.Main /path/to/Java; Properties -- java -Dpath.to.java=/path/to/java; etc.

    If you want true platform independence, then your whole scheme is flawed because the existence of a JVM executable is not guaranteed. I could imagine a JVM with no need for a java executable.

    If you want 99.99% platform independence, then I think you have the tools needed.

提交回复
热议问题