Skip to content

Commit 02f7975

Browse files
authored
Merge pull request #1199 from Stefterv/fix-java-home
Set `java.home` and added some comments
2 parents 475d405 + 39a0432 commit 02f7975

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

app/src/processing/app/Platform.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ static public void init() {
105105
"An unknown error occurred while trying to load\n" +
106106
"platform-specific code for your machine.", e);
107107
}
108+
109+
// Fix the issue where `java.home` points to the JRE instead of the JDK. processing/processing4#1163
110+
System.setProperty("java.home", getJavaHome().getAbsolutePath());
108111
}
109112

110113

@@ -389,6 +392,7 @@ static public File getContentFile(String name) {
389392
}
390393

391394
static public File getJavaHome() {
395+
// Get the build in JDK location from the Jetpack Compose resources
392396
var resourcesDir = System.getProperty("compose.application.resources.dir");
393397
if(resourcesDir != null) {
394398
var jdkFolder = new File(resourcesDir,"jdk");
@@ -397,10 +401,13 @@ static public File getJavaHome() {
397401
}
398402
}
399403

404+
// If the JDK is set in the environment, use that.
400405
var home = System.getProperty("java.home");
401406
if(home != null){
402407
return new File(home);
403408
}
409+
410+
// Otherwise try to use the Ant embedded JDK.
404411
if (Platform.isMacOS()) {
405412
//return "Contents/PlugIns/jdk1.7.0_40.jdk/Contents/Home/jre/bin/java";
406413
File[] plugins = getContentFile("../PlugIns").listFiles((dir, name) -> dir.isDirectory() &&

0 commit comments

Comments
 (0)