简体   繁体   中英

How can I detect the java runtime in Mac OS X?

Our cocoa app may invoke a module that is written with Java, but the Java environment is not always installed on Mac OS X, especially in Mac OS 10.7.

So, how can I detect whether the java runtime exists or not before invoking the module with cocoa?

Try checking the value of `exec /usr/libexec/java_home` (note the backticks! not apostrophes!). This will give you the location of the current Java installation, and should include the version number.

You can use the command:

$ java -version

$ which java

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM