简体   繁体   English

如何在Mac OS X中检测Java运行时?

[英]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. 我们的可可应用程序可能会调用用Java编写的模块,但是Java环境并非总是安装在Mac OS X上,尤其是在Mac OS 10.7中。

So, how can I detect whether the java runtime exists or not before invoking the module with cocoa? 因此,在用可可调用模块之前,如何检测Java运行时是否存在?

Try checking the value of `exec /usr/libexec/java_home` (note the backticks! not apostrophes!). 尝试检查exec / usr / libexec / java_home的值(注意反引号!不要撇号!)。 This will give you the location of the current Java installation, and should include the version number. 这将为您提供当前Java安装的位置,并应包括版本号。

You can use the command: 您可以使用以下命令:

$ java -version

$ which java

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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