@@ -1118,23 +1118,24 @@ protected boolean exportApplication() throws IOException, SketchException {
11181118
11191119 File folder = null ;
11201120 String platformName = Base .getPlatformName ();
1121+ boolean embedJava = Preferences .getBoolean ("export.application.embed_java" );
11211122 if (Library .hasMultipleArch (PApplet .platform , importedLibraries )) {
11221123 if (Base .getNativeBits () == 32 ) {
11231124 // export the 32-bit version
11241125 folder = new File (sketch .getFolder (), "application." + platformName + "32" );
1125- if (!exportApplication (folder , PApplet .platform , 32 )) {
1126+ if (!exportApplication (folder , PApplet .platform , 32 , embedJava )) {
11261127 return false ;
11271128 }
11281129 } else if (Base .getNativeBits () == 64 ) {
11291130 // export the 64-bit version
11301131 folder = new File (sketch .getFolder (), "application." + platformName + "64" );
1131- if (!exportApplication (folder , PApplet .platform , 64 )) {
1132+ if (!exportApplication (folder , PApplet .platform , 64 , embedJava )) {
11321133 return false ;
11331134 }
11341135 }
11351136 } else { // just make a single one for this platform
11361137 folder = new File (sketch .getFolder (), "application." + platformName );
1137- if (!exportApplication (folder , PApplet .platform , 0 )) {
1138+ if (!exportApplication (folder , PApplet .platform , 0 , embedJava )) {
11381139 return false ;
11391140 }
11401141 }
@@ -1147,7 +1148,8 @@ protected boolean exportApplication() throws IOException, SketchException {
11471148 */
11481149 protected boolean exportApplication (File destFolder ,
11491150 int exportPlatform ,
1150- int exportBits ) throws IOException , SketchException {
1151+ int exportBits ,
1152+ boolean embedJava ) throws IOException , SketchException {
11511153 // TODO this should probably be a dialog box instead of a warning
11521154 // on the terminal. And the message should be written better than this.
11531155 // http://code.google.com/p/processing/issues/detail?id=884
@@ -1178,13 +1180,18 @@ protected boolean exportApplication(File destFolder,
11781180 /// on macosx, need to copy .app skeleton since that's
11791181 /// also where the jar files will be placed
11801182 File dotAppFolder = null ;
1181- String jdkFolderName = null ;
1183+ // String jdkFolderName = null;
1184+ String jvmRuntime = "" ;
11821185 if (exportPlatform == PConstants .MACOSX ) {
11831186 dotAppFolder = new File (destFolder , sketch .getName () + ".app" );
11841187
11851188 File contentsOrig = new File (Base .getJavaHome (), "../../../../.." );
1186- File jdkFolder = new File (Base .getJavaHome (), "../../.." );
1187- jdkFolderName = jdkFolder .getCanonicalFile ().getName ();
1189+
1190+ if (embedJava ) {
1191+ File jdkFolder = new File (Base .getJavaHome (), "../../.." );
1192+ String jdkFolderName = jdkFolder .getCanonicalFile ().getName ();
1193+ jvmRuntime = "<key>JVMRuntime</key>\n <string>" + jdkFolderName + "</string>" ;
1194+ }
11881195
11891196// File dotAppSkeleton = mode.getContentFile("application/template.app");
11901197// Base.copyDir(dotAppSkeleton, dotAppFolder);
@@ -1209,8 +1216,10 @@ protected boolean exportApplication(File destFolder,
12091216 writer .close ();
12101217
12111218 // Use faster(?) native copy here (also to do sym links)
1212- Base .copyDirNative (new File (contentsOrig , "PlugIns" ),
1213- new File (contentsFolder , "PlugIns" ));
1219+ if (embedJava ) {
1220+ Base .copyDirNative (new File (contentsOrig , "PlugIns" ),
1221+ new File (contentsFolder , "PlugIns" ));
1222+ }
12141223
12151224 File resourcesFolder = new File (contentsFolder , "Resources" );
12161225 Base .copyDir (new File (contentsOrig , "Resources/en.lproj" ),
@@ -1243,10 +1252,14 @@ protected boolean exportApplication(File destFolder,
12431252 }
12441253 */
12451254 } else if (exportPlatform == PConstants .LINUX ) {
1246- Base .copyDirNative (Base .getJavaHome (), new File (destFolder , "java" ));
1255+ if (embedJava ) {
1256+ Base .copyDirNative (Base .getJavaHome (), new File (destFolder , "java" ));
1257+ }
12471258
12481259 } else if (exportPlatform == PConstants .WINDOWS ) {
1249- Base .copyDir (Base .getJavaHome (), new File (destFolder , "java" ));
1260+ if (embedJava ) {
1261+ Base .copyDir (Base .getJavaHome (), new File (destFolder , "java" ));
1262+ }
12501263 }
12511264
12521265
@@ -1480,9 +1493,9 @@ protected boolean exportApplication(File destFolder,
14801493 if (lines [i ].indexOf ("@@" ) != -1 ) {
14811494 StringBuffer sb = new StringBuffer (lines [i ]);
14821495 int index = 0 ;
1483- while ((index = sb .indexOf ("@@jdk_folder @@" )) != -1 ) {
1484- sb .replace (index , index + "@@jdk_folder @@" .length (),
1485- jdkFolderName );
1496+ while ((index = sb .indexOf ("@@jvm_runtime @@" )) != -1 ) {
1497+ sb .replace (index , index + "@@jvm_runtime @@" .length (),
1498+ jvmRuntime );
14861499 }
14871500 while ((index = sb .indexOf ("@@jvm_options_list@@" )) != -1 ) {
14881501 sb .replace (index , index + "@@jvm_options_list@@" .length (),
0 commit comments