-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathfind_java.java
44 lines (35 loc) · 1.57 KB
/
find_java.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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);
}
}