-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add example of using JNE to help find a locale JDK
- Loading branch information
Showing
2 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
blaze.dependencies = [ | ||
"com.fizzed:jne:4.1.1" | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import com.fizzed.blaze.Contexts; | ||
import org.slf4j.Logger; | ||
import com.fizzed.jne.*; | ||
|
||
import java.util.List; | ||
|
||
public class find_java { | ||
|
||
final private Logger log = Contexts.logger(); | ||
|
||
public void main() throws Exception { | ||
log.info("Finding all JVMs on your system..."); | ||
|
||
final List<JavaHome> javaHomes = JavaHomes.detect(); | ||
|
||
for (JavaHome javaHome : javaHomes) { | ||
log.info("{}", javaHome); | ||
log.info(" javaExe: {}", javaHome.getJavaExe()); | ||
log.info(" javacExe: {}", javaHome.getJavacExe()); | ||
log.info(" nativeImageExe: {}", javaHome.getNativeImageExe()); | ||
log.info(" imageType: {}", javaHome.getImageType()); | ||
log.info(" version: {}", javaHome.getVersion()); | ||
log.info(" major: {}", javaHome.getVersion().getMajor()); | ||
log.info(" minor: {}", javaHome.getVersion().getMinor()); | ||
log.info(" security: {}", javaHome.getVersion().getSecurity()); | ||
log.info(" os: {}", javaHome.getOperatingSystem()); | ||
log.info(" arch: {}", javaHome.getHardwareArchitecture()); | ||
log.info(" distro: {}", javaHome.getDistribution()); | ||
log.info(" vendor: {}", javaHome.getVendor()); | ||
} | ||
|
||
// now, let's use the JavaHomeFinder to narrow our match to something awesome | ||
final JavaHome jdk = new JavaHomeFinder() | ||
.jdk() | ||
.maxVersion(21) | ||
.minVersion(8) | ||
.preferredDistributions() | ||
.sorted() | ||
.find(); | ||
|
||
log.info("Found JVM {}", jdk); | ||
} | ||
|
||
} |