简体   繁体   English

如何检查是否通过Cocoa安装了Java 7版本?

[英]How to check if Java 7 version is installed via Cocoa?

I have an Cocoa Xcode application that I am writing and I need to check what Java versions are installed on the user's machine. 我有一个我正在编写的Cocoa Xcode应用程序,我需要检查用户机器上安装的Java版本。 I know I can check /System/Library/Frameworks/JavaVM.framework/Versions/ and see what folders exist; 我知道我可以查看/System/Library/Frameworks/JavaVM.framework/Versions/并查看存在哪些文件夹; however, this does not work for Java 7. 但是,这对Java 7不起作用。

When I installed Java 7 on my Mac OS X 10.7.5, it was installed to /Library/Internet Plugins/JavaAppletPlugin.plugin . 当我在Mac OS X 10.7.5上安装Java 7时,它被安装到/Library/Internet Plugins/JavaAppletPlugin.plugin But this doesn't let me know the version of Java that is installed. 但这并不让我知道安装的Java版本。 If a newer version of Java is installed, I'm assuming it will install to the same place. 如果安装了较新版本的Java,我假设它将安装到同一个地方。

If I need to test if Java 7+ JRE is installed on the user's machine, should I just check if the file /Library/Internet Plugins/JavaAppletPlugin.plugin exists? 如果我需要测试用户机器上是否安装了Java 7+ JRE,我应该检查文件/Library/Internet Plugins/JavaAppletPlugin.plugin存在? Is there a better way to check? 有更好的检查方法吗?

Although you may have installed Java 7, you should have installed the Apple's Java Mac OS X 2012-006 update before. 虽然您可能已经安装了Java 7,但您之前应该已经安装了Apple的Java Mac OS X 2012-006更新。 Having done that (and then installed java 7 again), java -version should tell you java version "1.7.x..." 完成后(再安装java 7),java -version应该告诉你java版“1.7.x ......”

Determining the Default Version of the JDK 确定JDK的默认版本

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

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