Skip to content

Commit

Permalink
Application export JDK and resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefterv committed Jan 10, 2025
1 parent 6df3bd4 commit 6eb3b14
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
7 changes: 7 additions & 0 deletions java/application/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -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.";
27 changes: 26 additions & 1 deletion java/src/processing/mode/java/JavaBuild.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
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;
Expand Down Expand Up @@ -732,7 +733,8 @@ protected boolean exportApplication(File destFolder,
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"),
Expand All @@ -744,6 +746,29 @@ protected boolean exportApplication(File destFolder,
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

Expand Down

0 comments on commit 6eb3b14

Please sign in to comment.