Finding Java Version Greater Than X

I’m hitting a slight road block and hoping someone might be able to help me get over it. To make possibly make it easier to help me out I’ll give you some background on what I’m trying to accomplish. We install the latest Java runtime version quarterly within my company and there are about 10 machines that run a program that has issues with the latest versions of Java. I’m able to fix those machines by editing a java file local on the machines. With that information I would like to create a relevance that will report true when a new version of Java is installed on the machines. I want to relevance to look at a registry value that I will be creating and compare that to the different versions of Java installed on the machine. Once a version has been installed that is higher than the one I’m providing in a registry value the machine should report relevant for my task. I’m having issues with the version comparison part.

So for example Java version 8.0.1510.12 is installed on a machine. I fix the issue with the java file and then update a registry value with 8.0.1510.12. The same should no longer report for my task as the java versions match. Java version 8.0.1610.12 is then installed months later. Now the java version is higher than the value I put in so the machine should report relevant for the task again.

Here is what I have so far. I have 8.0.1610.12 installed on my machine but this does not report back 8.0.1610.12 like it should. I just can’t figure out what I’m missing and any help with this would be appreciated.

(value "PRODUCTVERSION" of it) of keys whose (exists value "PRODUCTVERSION" of it whose ("PRODUCTVERSION" > "8.0.1510.12" as string as version)) of key "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" of registry
1 Like

I would recommend taking a step back and try to read the raw values instead of trying to jump to a solution. Put something like this in an analysis property: (set to something like once a day for report interval)

(it as string) of values "PRODUCTVERSION" of keys of keys "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" of (x64 registries; x32 registries)

Only when you get it to return ALL values, should you try to narrow it down:

unique values whose(it > "8.0.1510.12") of (it as string as version) of values "PRODUCTVERSION" of keys of keys "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" of (x64 registries; x32 registries)

And only when you get results like you expect, should you turn it into true/false for applicability:

exists unique values whose(it > "8.0.1510.12") of (it as string as version) of values "PRODUCTVERSION" of keys of keys "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" of (x64 registries; x32 registries)

This part is incorrect and will always be false or an error.

This is like saying "Candy" > "8"

It would need to be more like this:

(exists values "PRODUCTVERSION" whose(it as string as version > "8.0.1510.12") of it)

Thanks jgstew! That worked out perfectly.

1 Like

Sorry to semi reopen this but I have a follow up question and you may not know the answer to it. This code works perfectly for my Windows 10 machine but fails for Windows 7 x32.

exists unique values whose(it > ((value "eClient_Java_Version" of it) of key "HKEY_LOCAL_MACHINE\SOFTWARE\NCFB_Custom_Fixes" of (x64 registries; x32 registries)) as string) of (it as string as version) of values "PRODUCTVERSION" of keys of keys "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" of (x64 registries; x32 registries)

This code works for the Windows 10 and Windows 7 machines.

exists unique values whose(it > ((value "eClient_Java_Version" of it) of key "HKEY_LOCAL_MACHINE\SOFTWARE\NCFB_Custom_Fixes" of (x64 registries; x32 registries)) as string) of (it as string as version) of values "PRODUCTVERSION" **of keys** of keys of keys "HKEY_LOCAL_MACHINE\SOFTWARE\JavaSoft\Java Runtime Environment" of (x64 registries; x32 registries)

I ended up having to add a third “of keys” to get it to work for by OS’s. I can see why adding the third of keys works because there are two additional keys before you get to the PRODUCTVERSION value but is it a bug that the Windows 10 machine worked without the third entry? Both machines are running the same version of the BigFix client.

Is there something like this for Linux or Solaris?