如何检测Java运行时是否安装或不 [英] How to detect whether Java runtime is installed or not

查看:143
本文介绍了如何检测Java运行时是否安装或不的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编程使用Java的Windows应用程序,这构建了的.jar文件不是一个.exe文件。当客户端计算机没有安装Java运行时打开的.jar的文件,它会作为用WinRAR存档。所有我想知道的是如何检测的Java运行时是否使用,以C#代码显示一个消息框,告诉用户安装Java运行时安装或无法在电脑上,或启动了的.jar文件中使用的Java运行时,如果它的安装

I program windows applications using Java and this builds a ".jar" file not an ".exe" file. When a client computer with no java runtime installed opens the ".jar" file, it runs as an archive with winrar. All I want to know is how to detect whether java runtime is installed or not on a computer using c# code in order to show a MessageBox telling user to install java runtime, or launches the ".jar" file using the java runtime if it's installed.

推荐答案

您可以检查注册表

RegistryKey rk = Registry.LocalMachine;
RegistryKey subKey = rk.OpenSubKey("SOFTWARE\\JavaSoft\\Java Runtime Environment");

string currentVerion = subKey.GetValue("CurrentVersion").ToString();

这篇关于如何检测Java运行时是否安装或不的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆