diff --git a/app/src/processing/app/Base.java b/app/src/processing/app/Base.java
index 74bda230e..a3584a407 100644
--- a/app/src/processing/app/Base.java
+++ b/app/src/processing/app/Base.java
@@ -2401,12 +2401,26 @@ public class Base {
}
-// static public File getJavaHome() {
-// }
+ static public File getJavaHome() {
+ if (isMacOS()) {
+ //return "Contents/PlugIns/jdk1.7.0_40.jdk/Contents/Home/jre/bin/java";
+ File[] plugins = getContentFile("../PlugIns").listFiles(new FilenameFilter() {
+ public boolean accept(File dir, String name) {
+ return name.endsWith(".jdk") && dir.isDirectory();
+ }
+ });
+ return new File(plugins[0], "Contents/Home/jre");
+ }
+ // On all other platforms, it's the 'java' folder adjacent to Processing
+ return getContentFile("java");
+ }
/** Get the path to the embedded Java executable. */
static public String getJavaPath() {
+ String javaPath = "bin/java" + (isWindows() ? ".exe" : "");
+ return new File(getJavaHome(), javaPath).getAbsolutePath();
+ /*
if (isMacOS()) {
//return "Contents/PlugIns/jdk1.7.0_40.jdk/Contents/Home/jre/bin/java";
File[] plugins = getContentFile("../PlugIns").listFiles(new FilenameFilter() {
@@ -2429,6 +2443,7 @@ public class Base {
System.err.println("No appropriate platform found. " +
"Hoping that Java is in the path.");
return Base.isWindows() ? "java.exe" : "java";
+ */
}
@@ -2569,6 +2584,7 @@ public class Base {
to = null;
targetFile.setLastModified(sourceFile.lastModified());
+ targetFile.setExecutable(sourceFile.canExecute());
}
@@ -2639,6 +2655,28 @@ public class Base {
}
}
}
+
+
+ static public void copyDirNative(File sourceDir,
+ File targetDir) throws IOException {
+ Process process = null;
+ if (Base.isMacOS() || Base.isLinux()) {
+ process = Runtime.getRuntime().exec(new String[] {
+ "cp", "-a", sourceDir.getAbsolutePath(), targetDir.getAbsolutePath()
+ });
+ } else {
+ // TODO implement version that uses XCOPY here on Windows
+ throw new RuntimeException("Not yet implemented on Windows");
+ }
+ try {
+ int result = process.waitFor();
+ if (result != 0) {
+ throw new IOException("Error while copying (result " + result + ")");
+ }
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
/**
diff --git a/app/src/processing/mode/java/JavaBuild.java b/app/src/processing/mode/java/JavaBuild.java
index 43112e227..cb80b60e2 100644
--- a/app/src/processing/mode/java/JavaBuild.java
+++ b/app/src/processing/mode/java/JavaBuild.java
@@ -1162,11 +1162,42 @@ public class JavaBuild {
File dotAppFolder = null;
if (exportPlatform == PConstants.MACOSX) {
dotAppFolder = new File(destFolder, sketch.getName() + ".app");
-// String APP_SKELETON = "skeleton.app";
- //File dotAppSkeleton = new File(folder, APP_SKELETON);
- File dotAppSkeleton = mode.getContentFile("application/template.app");
- Base.copyDir(dotAppSkeleton, dotAppFolder);
+ File contentsOrig = new File(Base.getJavaHome(), "../../../../..");
+
+// File dotAppSkeleton = mode.getContentFile("application/template.app");
+// Base.copyDir(dotAppSkeleton, dotAppFolder);
+ File contentsFolder = new File(dotAppFolder, "Contents");
+ contentsFolder.mkdirs();
+
+ // Info.plist will be written later
+
+ // set the jar folder to a different location than windows/linux
+ //jarFolder = new File(dotAppFolder, "Contents/Resources/Java");
+ jarFolder = new File(contentsFolder, "Java");
+
+ File macosFolder = new File(contentsFolder, "MacOS");
+ macosFolder.mkdirs();
+ Base.copyFile(new File(contentsOrig, "MacOS/Processing"),
+ new File(contentsFolder, "MacOS/" + sketch.getName()));
+
+ File pkgInfo = new File(contentsFolder, "PkgInfo");
+ PrintWriter writer = PApplet.createWriter(pkgInfo);
+ writer.println("APPL????");
+ writer.flush();
+ writer.close();
+
+ // Use faster(?) native copy here (also to do sym links)
+ Base.copyDirNative(new File(contentsOrig, "PlugIns"),
+ new File(contentsFolder, "PlugIns"));
+
+ File resourcesFolder = new File(contentsFolder, "Resources");
+ Base.copyDir(new File(contentsOrig, "Resources/en.lproj"),
+ new File(resourcesFolder, "en.lproj"));
+ Base.copyFile(mode.getContentFile("application/sketch.icns"),
+ new File(resourcesFolder, "sketch.icns"));
+
+ /*
String stubName = "Contents/MacOS/JavaApplicationStub";
// need to set the stub to executable
// will work on osx or *nix, but just dies on windows, oh well..
@@ -1189,13 +1220,11 @@ public class JavaBuild {
String stubPath = stubFile.getAbsolutePath();
Runtime.getRuntime().exec(new String[] { "chmod", "+x", stubPath });
}
-
- // set the jar folder to a different location than windows/linux
- jarFolder = new File(dotAppFolder, "Contents/Resources/Java");
+ */
}
- /// make the jar folder (windows and linux)
+ /// make the jar folder (all platforms)
if (!jarFolder.exists()) jarFolder.mkdirs();
diff --git a/build/build.xml b/build/build.xml
index 324fed312..f538c898e 100755
--- a/build/build.xml
+++ b/build/build.xml
@@ -542,11 +542,11 @@
-->
-
-
-
-
-
+
+
+
+
+