Finds installed Java versions on the system by looking through common paths on Windows, Linux, and macOS.
The returned List is sorted from newest to oldest Java version, with JDKs listed before JREs of the same version. When ran directly with java -jar, it prints the list to STDOUT, marking the currently running java version with an asterisk (*):
The dependency is available on Maven Central:
<dependencies>
<dependency>
<groupId>com.jeff-media</groupId>
<artifactId>javafinder</artifactId>
<version>1.4.3</version>
</dependency>
</dependencies>
Print to stdout from command line:
java -jar javafinder-1.4.3.jar
Or through Java code:
Collection<JavaInstallation> installations = JavaFinder.builder().build().findInstallations()
- Parent folder of current $JAVA_HOME (unless that directory is the same as $HOME)
- $HOME/.sdkman/candidates/java
- Every folder in $ProgramFiles or $ProgramFiles(x86) containing "Java", "JDK", or "JRE" (case-insensitive)
- $ProgramFiles/Eclipse Foundation
- $ProgramFiles/Eclipse Adoptium
- /usr/lib/jvm
- /Library/Java/JavaVirtualMachines
- /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
- $HOME/Library/Java/JavaVirtualMachines