### Check Java Version

Checking the installed Java version on the OS is useful to ensure App or Library can run / used.
'Check the installed java version
'Parameter: Target Java version in format mainversion.subversion.build_subbuild
'Example Parameter: 1.8.0_45
'Dim JavaVersionTarget As String = "1.8.0_50"
'If CheckJavaVersion(JavaVersionTarget) = False Then
' Log("This App requires Java Version " & JavaVersionTarget & ". Your version is " & GetSystemProperty("java.version","0.0.0_00"))
' ExitApplication
'End If
`Sub CheckJavaVersion(sJavaVersionTarget As String) As Boolean
Dim result As Boolean = True
Dim sJavaVersionCurrent As String = GetSystemProperty("java.version","0.0.0_00")
'Clean up the version information by removing . and _
sJavaVersionCurrent = sJavaVersionCurrent.Replace(".", "").Replace("_", "")
sJavaVersionTarget = sJavaVersionTarget.Replace(".", "").Replace("_", "")
'Convert into int to be able to compare
Dim nJavaVersionCurrent As Int = sJavaVersionCurrent
Dim nJavaVersionTarget As Int = sJavaVersionTarget
If nJavaVersionCurrent < nJavaVersionTarget Then
result = False
End If
Return result
End Sub`
Sub Get Java Version
`Sub GetJavaVersion As String
Return GetSystemProperty("java.version","0.0.0_00")
End Sub`
Output
1.8.0_131

Changed: 2018-04-19 09:34, Category: Application, File: T6C159M1142.htm, ID: 1142