我想检查JDK是否已安装。
我不想检查C:\Program Files\Java\jdk1.8.0_25
是否存在,因为用户可能安装了旧版本。
我想检查C:\Program Files\Java
中是否包含字符串jdk
。
我能这样做吗?
答案 0 :(得分:0)
答案 1 :(得分:0)
Dim Installed = (
From i In My.Computer.FileSystem.GetDirectories("C:\Program Files\Java")
Where i.ToLower Like "*jdk*").Any
答案 2 :(得分:0)
简单的注册表检查。您需要添加错误捕获等。
Dim rk As RegistryKey
Dim sk As RegistryKey
Dim currentVerion As String
rk = Registry.LocalMachine
sk = rk.OpenSubKey("SOFTWARE\\JavaSoft\\Java Runtime Environment")
If sk Is Nothing Then
'Does not exist (IE Could not open it).
Else
currentVerion = sk.GetValue("CurrentVersion").ToString()
End If
答案 3 :(得分:-1)
直接来自MSDN。
Try
Dim dirPath As String = "your directory where JDK might be present"
Dim dirs As List(Of String) = New List(Of String)(Directory.EnumerateDirectories(dirPath))
For Each folder In dirs
' Logic to check existence of word "JDK" from end
' If found break
Next
Catch UAEx As UnauthorizedAccessException
' Error Handling
Catch PathEx As PathTooLongException
' Error Handling
End Try