Skip to content

mfnalex/javafinder

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaFinder

Javadocs Discord Donate

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 (*):

image

Maven

The dependency is available on Maven Central:

<dependencies>
    <dependency>
        <groupId>com.jeff-media</groupId>
        <artifactId>javafinder</artifactId>
        <version>1.4.3</version>
    </dependency>
</dependencies>

Usage

Print to stdout from command line:

java -jar javafinder-1.4.3.jar

Or through Java code:

Collection<JavaInstallation> installations = JavaFinder.builder().build().findInstallations()

List of checked locations

Universal

  • Parent folder of current $JAVA_HOME (unless that directory is the same as $HOME)
  • $HOME/.sdkman/candidates/java

Windows

  • Every folder in $ProgramFiles or $ProgramFiles(x86) containing "Java", "JDK", or "JRE" (case-insensitive)
  • $ProgramFiles/Eclipse Foundation
  • $ProgramFiles/Eclipse Adoptium

Linux

  • /usr/lib/jvm

macOS

  • /Library/Java/JavaVirtualMachines
  • /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
  • $HOME/Library/Java/JavaVirtualMachines