markdown-writer-fx icon indicating copy to clipboard operation
markdown-writer-fx copied to clipboard

Java 11 is not supported at runtime

Open s17t opened this issue 5 years ago • 3 comments

Java 11 moved JavaFX libraries out from the base JDK/JRE. JavaFX must be (re)packaged by applications, thus the 0.11 version of markdown-writer-fx can't be executed on java 11. On Linux I get:

./bin/markdown-writer-fx     
Error: Could not find or load main class org.markdownwriterfx.MarkdownWriterFXApp
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

JavaFX is available on maven central with org.openjfx groupId [0]

openjdk version "11.0.1" 2018-10-16
OpenJDK Runtime Environment (build 11.0.1+13-Ubuntu-2ubuntu1)
OpenJDK 64-Bit Server VM (build 11.0.1+13-Ubuntu-2ubuntu1, mixed mode, sharing)

[0] https://wiki.openjdk.java.net/display/OpenJFX/Main

s17t avatar Jan 30 '19 16:01 s17t

Yes, this is a known issue.

MWFX 0.11 requires Java 8.

Even Java 9 will not work because ControlsFX 9.0.0 is required for Java 9, but MWFX 0.11 ships with ControlsFX 8.40.14.

I plan to distribute one of the next releases of MWFX with bundled Java 11 JRE and bundled JavaFX 11. For now, I've updated the readme and the release notes to clarify the current Java requirements.

JFormDesigner avatar Jan 30 '19 16:01 JFormDesigner

Well, after some head scratching with master branch I come up with this:

  • Add javafx-media dependency:
compile( "org.openjfx:javafx-media:${javafxVersion}:${platform}" )
  • Compile and create a dist with ./gradlew distZip
  • Add the following module add-opens in the markdown-writer-fx. These can be migrated in the JAR's manifest adapting the syntax. Probably it is not the right way to work around the module system but it works.
DEFAULT_JVM_OPTS="--module-path ./lib --add-modules=javafx.controls --add-opens javafx.graphics/javafx.scene=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.javafx.sg.prism=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.javafx.util=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.prism=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.glass.ui=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.javafx.tk=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.glass.utils=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.javafx.font=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.javafx.geom.transform=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.javafx.scene.input=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.javafx.application=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.prism.paint=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.scenario.effect=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.scenario.effect.impl.prism=ALL-UNNAMED \
--add-opens javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED \
--add-opens javafx.base/com.sun.javafx.logging=ALL-UNNAMED \
--add-opens javafx.graphics/javafx.scene.text=ALL-UNNAMED \
--add-opens javafx.graphics/com.sun.javafx.text=ALL-UNNAMED \
--add-exports javafx.graphics/com.sun.javafx.geom=ALL-UNNAMED \
--add-exports javafx.graphics/com.sun.javafx.text=ALL-UNNAMED \
--add-exports javafx.graphics/com.sun.javafx.scene.text=ALL-UNNAMED"

s17t avatar Jan 30 '19 17:01 s17t

Create a class like this:

public class Main {

	public static void main(String[] args) {
		Application.launch(MarkdownWriterFXApp.class);
	}

}

then run Main.main

yuchuangu85 avatar Dec 21 '21 14:12 yuchuangu85

Fixed in 1.0: https://github.com/JFormDesigner/markdown-writer-fx/releases

DevCharly avatar Mar 18 '23 17:03 DevCharly