I would like to find the JDK path on multiple operating systems.
I'm not sure if there's a nice way of doing this as I've been trying and failing.
For Windows it would be something like this - C:\Program Files\Java\jdk1.7.0_07
or this
C:\Program Files(x86)\Java\jdk1.7.0_07
For Linux it would be something like this - /usr/java/jdk1.7.0_07
I want this to work for any version of JDK installed, so the numbers after Java\jdk are irrelevant.
I will be using System.setProperty("java.home", path);
Basically, what I am looking to do is when I run my program, set java.home to be the JDK installed on the current machine, but getting the JDK path is proving very difficult, any solutions?