Application export JDK and resources

This commit is contained in:
Stef Tervelde
2025-01-10 08:43:15 +01:00
parent 6df3bd4d3e
commit 6eb3b14612
2 changed files with 33 additions and 1 deletions
@@ -0,0 +1,7 @@
"JRELoadError" = "Unable to load Java Runtime Environment.";
"JRExLoadError" = "Unable to load a Java %d Runtime Environment.";
"JRExLoadFullError" = "This application requires that Java %d or later be installed on your computer. Please download and install the latest version of Java from www.java.com and try again.";
"JDKxLoadFullError" = "This application requires that a Java %d JDK or later be installed on your computer. Please download and install the latest Java JDK from Oracle.com and try again.";
"MainClassNameRequired" = "Main class name is required.";
"JavaDirectoryNotFound" = "Unable to enumerate Java directory contents.";
"BundlePathContainsColon" = "Cannot launch from folder that contains a \"/\" in its name.";
+26 -1
View File
@@ -24,6 +24,7 @@ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
package processing.mode.java;
import java.io.*;
import java.nio.file.Files;
import java.util.*;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@@ -732,7 +733,8 @@ public class JavaBuild {
writer.println("APPL????");
writer.flush();
writer.close();
if(System.getProperty("compose.application.resources.dir") == null) {
var resources = System.getProperty("compose.application.resources.dir");
if(resources == null) {
// Use faster(?) native copy here (also to do sym links)
if (embedJava) {
Util.copyDirNative(new File(contentsOrig, "PlugIns"),
@@ -744,6 +746,29 @@ public class JavaBuild {
new File(resourcesFolder, "en.lproj"));
Util.copyFile(mode.getContentFile("application/application.icns"),
new File(resourcesFolder, "application.icns"));
}else{
if(embedJava){
try {
var jdk = Files.list(new File(resources).toPath())
.filter(Files::isDirectory)
.filter(p -> p.getFileName().toString().startsWith("jdk-"))
.findFirst()
.orElseThrow();
var target = new File(contentsFolder, "PlugIns/");
target.mkdirs();
Util.copyDirNative(jdk.toFile(), target);
} catch (IOException e) {
e.printStackTrace();
}
Util.copyDir(new File(resources, "modes/java/application/en.lproj"),
new File(contentsFolder, "Resources/en.lproj"));
Util.copyFile(new File(resources, "modes/java/application/application.icns"),
new File(contentsFolder, "Resources/application.icns"));
}
}
// TODO: Handle the java embed and Icon with the new build system