From 39a0432852e7a57192b29a43c138a8ec26e2c512 Mon Sep 17 00:00:00 2001 From: Stef Tervelde Date: Tue, 12 Aug 2025 13:38:47 +0200 Subject: [PATCH] Set `java.home` and added some comments --- app/src/processing/app/Platform.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/processing/app/Platform.java b/app/src/processing/app/Platform.java index b911d7e0ae..2c2ade5e12 100644 --- a/app/src/processing/app/Platform.java +++ b/app/src/processing/app/Platform.java @@ -105,6 +105,9 @@ static public void init() { "An unknown error occurred while trying to load\n" + "platform-specific code for your machine.", e); } + + // Fix the issue where `java.home` points to the JRE instead of the JDK. processing/processing4#1163 + System.setProperty("java.home", getJavaHome().getAbsolutePath()); } @@ -389,6 +392,7 @@ static public File getContentFile(String name) { } static public File getJavaHome() { + // Get the build in JDK location from the Jetpack Compose resources var resourcesDir = System.getProperty("compose.application.resources.dir"); if(resourcesDir != null) { var jdkFolder = new File(resourcesDir,"jdk"); @@ -397,10 +401,13 @@ static public File getJavaHome() { } } + // If the JDK is set in the environment, use that. var home = System.getProperty("java.home"); if(home != null){ return new File(home); } + + // Otherwise try to use the Ant embedded JDK. if (Platform.isMacOS()) { //return "Contents/PlugIns/jdk1.7.0_40.jdk/Contents/Home/jre/bin/java"; File[] plugins = getContentFile("../PlugIns").listFiles((dir, name) -> dir.isDirectory() &&