检查机器上是否已经安装了Tomcat和MySQL [英] Check if Tomcat and MySQL are already installed on machine
问题描述
如何在机器上已经安装了Tomcat和MySQL的情况下使用Java进行检查?如果已安装,则必须在安装程序中禁用这些选项.
How can I check using Java if Tomcat and MySQL are already installed on machine? If it is installed I have to disable those options in my installer.
推荐答案
如果将Tomcat作为服务安装在Windows上,则可以检查注册表:
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Tomcat\[version]\InstallPath
.
If Tomcat is installed as a service on Windows, you can check the registry:
HKEY_LOCAL_MACHINE\SOFTWARE\Apache Software Foundation\Tomcat\[version]\InstallPath
.
要从Java读取注册表,您需要使用类似 JNA 之类的方法
Advapi32Util.registryGetKeys()
和Advapi32Util.registryGetStringValue()
可以提供帮助.
To read the registry from Java, you would need to use something like JNA, the methods
Advapi32Util.registryGetKeys()
and Advapi32Util.registryGetStringValue()
can help.
这篇关于检查机器上是否已经安装了Tomcat和MySQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!