Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find whether the JDK is openJDK or Oracle JDK

Tags:

java

I am building a application where user can change the Java setting and can point to any jdk. However it must be Oracle JDK and shouldn't be a openJDK. Is there any way to check whether the JDK is open JDK or Oracle JDK given its java path c:\bin\jdk\binjava.exe ?

like image 895
Lolly Avatar asked Oct 27 '25 06:10

Lolly


1 Answers

The easiest way would be to System.exec()

c:\bin\jdk\bin\java.exe -version

and parse it's output. OpenJDK and Sun JDK have different text outputs.

This is not optimal, but consider: Even if you find a difference in classname, functionality or similar, it would still only work for certain versions. You could never rely on a difference staying different.

like image 144
0xCAFEBABE Avatar answered Oct 29 '25 21:10

0xCAFEBABE