如何获得当前可用的Java版本?
我如何使用C#获取当前的Java版本?
How do i get the current Java version available using c#?
我已经能够找到一种方法,使用C#来获得我的电脑上的Java版本,但我需要能够安装的版本可用的最新版本进行比较。此刻我无法找到一个API或Web服务来获取此信息。
I have been able to find a way to get the java version on my PC using C# but I need to be able to compare the installed version with the most current version available. At the moment I am unable to find an API or web service to get this information.
希望这里有人知道这个问题的答案。
Hopefully someone here knows the answer to this.
最新版本
您可以拉可以从这个页面下载最新的版本:
You can pull the current version available for download from this page:
http://java.com/en/download/index.jsp
使用此选择
.jvc0w2 > strong:nth-child(3)
喜欢的 HTML敏捷性包的C#使得这个简单的。
版本目前已安装
RegistryKey rk = Registry.LocalMachine;
RegistryKey subKey = rk.OpenSubKey("SOFTWARE\\JavaSoft\\Java Runtime Environment");
string currentVerion = subKey.GetValue("CurrentVersion").ToString();
注意事项
您将需要协调这两个字符串的格式进行比较。
You will need to reconcile the formats of these two strings for comparison.
如果我引用检查当前版本更改的网站,你可能需要更新您的选择。
If the website I referenced to check the current version changes, you will may need to update your selector.