@@ -281,7 +281,11 @@ public String preprocess(File srcFolder,
281281 if (library != null ) {
282282 if (!importedLibraries .contains (library )) {
283283 importedLibraries .add (library );
284- classPath += library .getClassPath ();
284+ // don't add the JavaFX libraries to the classpath
285+ // https://github.com/processing/processing4/issues/212
286+ if (!library .getName ().equals ("JavaFX" )) {
287+ classPath += library .getClassPath ();
288+ }
285289 javaLibraryPath += File .pathSeparator + library .getNativePath ();
286290 }
287291 } else {
@@ -440,13 +444,13 @@ public String getClassPath() {
440444 }
441445
442446
443- /** Returns the dummy "module" path so that JavaFX doesn't complain. */
444- public String getModulePath () {
445- // Just set this to the main core/library directory to pick up JavaFX
446- //return mode.getCoreLibrary().getLibraryPath();
447- File folder = new File (mode .getFolder (), "libraries/javafx/library" );
448- return folder .getAbsolutePath ();
449- }
447+ // /** Returns the dummy "module" path so that JavaFX doesn't complain. */
448+ // public String getModulePath() {
449+ // // Just set this to the main core/library directory to pick up JavaFX
450+ // //return mode.getCoreLibrary().getLibraryPath();
451+ // File folder = new File(mode.getFolder(), "libraries/javafx/library");
452+ // return folder.getAbsolutePath();
453+ // }
450454
451455
452456 /** Return the java.library.path for this sketch (for all the native DLLs etc). */
@@ -831,6 +835,14 @@ protected boolean exportApplication(File destFolder,
831835 runOptions .append ("-Djava.library.path=\" %EXEDIR%\\ lib\" " );
832836 }
833837
838+ Library javafx = findJavaFX ();
839+ if (javafx != null ) {
840+ String modulePath = exportPlatform == PConstants .MACOS ?
841+ "$APP_ROOT/Contents/Java/modules" : "lib/modules" ;
842+ for (String opt : getArgsJavaFX (modulePath )) {
843+ runOptions .append (opt );
844+ }
845+ }
834846
835847 /// macosx: write out Info.plist (template for classpath, etc)
836848
@@ -843,6 +855,7 @@ protected boolean exportApplication(File destFolder,
843855 runOptionsXML .append ('\n' );
844856 }
845857
858+
846859 String PLIST_TEMPLATE = "Info.plist.tmpl" ;
847860 File plistTemplate = new File (sketch .getFolder (), PLIST_TEMPLATE );
848861 if (!plistTemplate .exists ()) {
@@ -935,16 +948,13 @@ protected boolean exportApplication(File destFolder,
935948 for (String opt : runOptions ) {
936949 jre .addChild ("opt" ).setContent (opt );
937950 }
938-
939- final String [] fxOptions = new String []{
940- "--module-path=" + getModulePath (),
941- "--add-modules=javafx.base,javafx.graphics,javafx.swing" ,
942- "--add-exports=javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED" ,
943- "--add-exports=javafx.graphics/com.sun.glass.ui=ALL-UNNAMED"
944- };
945- for (String opt : fxOptions ) {
946- jre .addChild ("opt" ).setContent (opt );
951+ /*
952+ if (javafx != null) {
953+ for (String opt : getArgsJavaFX("lib")) {
954+ jre.addChild("opt").setContent(opt);
955+ }
947956 }
957+ */
948958
949959 config .save (configFile );
950960 project .save (buildFile );
@@ -1021,6 +1031,34 @@ protected boolean exportApplication(File destFolder,
10211031 }
10221032
10231033
1034+ // This is a workaround until a more complete solution is found.
1035+ public Library findJavaFX () {
1036+ for (Library library : getImportedLibraries ()) {
1037+ if (library .getName ().equals ("JavaFX" )) {
1038+ return library ;
1039+ }
1040+ }
1041+ return null ;
1042+ }
1043+
1044+
1045+ static public String [] getArgsJavaFX (String modulePath ) {
1046+ return new String [] {
1047+ "--module-path" , modulePath ,
1048+
1049+ // Full list of modules, let's not commit to all of these unless
1050+ // a compelling argument is made or a reason presents itself.
1051+ //"javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web"
1052+ "--add-modules" , "javafx.base,javafx.graphics,javafx.swing" ,
1053+
1054+ // TODO Presumably, this is only because com.sun.* classes are being used?
1055+ // https://github.com/processing/processing4/issues/208
1056+ "--add-exports" , "javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED" ,
1057+ "--add-exports" , "javafx.graphics/com.sun.glass.ui=ALL-UNNAMED"
1058+ };
1059+ }
1060+
1061+
10241062 static Boolean xcodeInstalled ;
10251063
10261064 static protected boolean isXcodeInstalled () {
0 commit comments