Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the current Java version available?

Tags:

java

c#

How do i get the current Java version available using c#?

I have been able to find a way to get the java version on my PC using C# but I need to be able to compare the installed version with the most current version available. At the moment I am unable to find an API or web service to get this information.

Hopefully someone here knows the answer to this.

like image 492
William Norris Avatar asked Oct 31 '25 01:10

William Norris


1 Answers

Latest version available

You can pull the current version available for download from this page:

http://java.com/en/download/index.jsp

using this selector

.jvc0w2 > strong:nth-child(3)

A library like HTML Agility Pack for C# makes this straightforward.

Version currently installed

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

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

Caveats

You will need to reconcile the formats of these two strings for comparison.

If the website I referenced to check the current version changes, you will may need to update your selector.

like image 103
Chris Ballance Avatar answered Nov 02 '25 15:11

Chris Ballance



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!