get installed JDK platform independent

This commit is contained in:
Stef Tervelde
2024-12-14 10:55:49 +01:00
parent 852454fa34
commit 4e893f9568
2 changed files with 12 additions and 6 deletions

2
.idea/misc.xml generated
View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="temurin-21" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" default="true" project-jdk-name="temurin-17" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@@ -429,11 +429,17 @@ public class Platform {
if(new File(home, "bin/java").exists()){
return new File(home);
}else{
// TODO make platform independent
// Windows: C:\Program Files\Eclipse Adoptium\jdk-17*
// macOS/Linux: /usr/lib/jvm/, /opt/, /Library/Java/JavaVirtualMachines/
return new File("/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home");
String os = System.getProperty("os.name").toLowerCase();
// Default installation paths for different operating systems
if (os.contains("windows")) {
var programFiles = new File(System.getenv("ProgramFiles"));
return new File(programFiles, "Eclipse Adoptium/jdk-17.0.10+7-hotspot");
} else if (os.contains("mac")) {
return new File("/Library/Java/JavaVirtualMachines/temurin-17.jdk/Contents/Home");
} else {
// Linux and others
return new File("/usr/lib/jvm/temurin-17-jdk");
}
}
}
if (Platform.isMacOS()) {