Can we successfully run RichTextFX with Java 11 ? If not what steps we can take to make it happen ?
Yes, RichTextFX 0.9.x does run on Java 11 but you'll need to add the following to your main application's JAR manifest (or the equivalent to the java command line):
Add-Exports: javafx.graphics/com.sun.javafx.geom javafx.graphics/com.sun.javafx.text javafx.graphics/com.sun.javafx.scene.text
Add-Opens: javafx.graphics/javafx.scene.text javafx.graphics/com.sun.javafx.text
This won't be necessary when RichTextFX 0.10 is released (hopefully early next year 2019).
@Jugen You think we can make this project modular :) I just jumped to Java 11 and learning about modularization .
RichTextFX depends on ReactFX, Flowless, UndoFx, and WellbehavedFx which (according to this article) should also all be made at least explicit automatic modules (via a JAR manifest entry). If this can be done then RichTextFX can also become a module.
At the very least there is a fat JAR (see manual download) that bundles all these dependencies together with RichTextFX which I think could easily be released as a module.
I'm trying to build on my Mac running OpenJDK 11.0.1.
When I run gradle, I see this:
yomigana:RichTextFX (master)$ gradle
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/duncan/git/RichTextFX/richtextfx/build.gradle' line: 13
* What went wrong:
A problem occurred evaluating project ':richtextfx'.
> Failed to apply plugin [id 'org.unbroken-dome.test-sets']
> Could not create an instance of type org.unbrokendome.gradle.plugins.testsets.internal.DefaultTestSetContainer_Decorated.
> java.lang.StackOverflowError (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1/userguide/command_line_interface.html#sec:command_line_warnings
@duncanmak use latest 5.X gradle. That might solve the issue.
Look at this message
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
@Adyel I'm building using Gradle 5.1.
I wonder if the issue is that the Gradle TestSets plugin needs updating.
yomigana:RichTextFX (master)$ gradle
Starting a Gradle Daemon (subsequent builds will be faster)
FAILURE: Build failed with an exception.
* Where:
Build file '/Users/duncan/git/RichTextFX/richtextfx/build.gradle' line: 13
* What went wrong:
A problem occurred evaluating project ':richtextfx'.
> Failed to apply plugin [id 'org.unbroken-dome.test-sets']
> Could not create an instance of type org.unbrokendome.gradle.plugins.testsets.internal.DefaultTestSetContainer_Decorated.
> java.lang.StackOverflowError (no error message)
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 6.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/5.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 8s
yomigana:RichTextFX (master)$ gradle --version
------------------------------------------------------------
Gradle 5.1
------------------------------------------------------------
Build time: 2019-01-02 18:57:47 UTC
Revision: d09c2e354576ac41078c322815cc6db2b66d976e
Kotlin DSL: 1.1.0
Kotlin: 1.3.11
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 11.0.1 (Oracle Corporation 11.0.1+13)
OS: Mac OS X 10.14.2 x86_64
I don't know why this works (I'm new to JDK11 and it's crazy modularization stuff) but here's the VM equivalent of Jugen's first reply. Or atleast, what I wrote to get my stuff to run. Someone please come correct me if it's wrong:
--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
--add-opens javafx.graphics/javafx.scene.text=ALL-UNNAMED
--add-opens javafx.graphics/com.sun.javafx.text=ALL-UNNAMED
I literally only got this to work by throwing a bunch of different configurations at the wall until it finally ran lol
Before read this, I apologize for my bad english.
I look for 4 hours a solution to this problem... I need learn more about modularization.
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make com.sun.javafx.scene.text.TextLayout javafx.scene.text.TextFlow.getTextLayout() accessible: module javafx.graphics does not "opens javafx.scene.text" to module richtextfx.fat
I tried to add:
--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 --add-opens javafx.graphics/javafx.scene.text=ALL-UNNAMED --add-opens javafx.graphics/com.sun.javafx.text=ALL-UNNAMED
in VM arguments in run configurations. (I'm using Eclipse IDE) But nothing work.
I know I have to add opens javaFX.scene.text but I don't know how to do this without VM-Args
Thanks
my english too..... :)
After trying long time I found this solution, not sure is the best:
-Create a module-info.java at root package of your project
-Add theses following lines
module nameOfYourModule{
exports yourMainPackage;
exports yourPackageUsingRichtextLib;
requires transitive javafx.controls;
requires transitive javafx.web;
requires transitive javafx.fxml;
requires transitive javafx.base;
requires transitive javafx.graphics;
requires transitive javafx.media;
requires transitive javafx.swing;
requires transitive java.management;
requires transitive java.xml.bind;
requires transitive java.instrument;
requires transitive java.activation;
requires transitive java.desktop;
requires transitive jfxtras.common;
requires transitive jfxtras.controls;
requires transitive richtextfx;
}
-Add the vm arguments :
--add-exports javafx.graphics/com.sun.javafx.geom=richtextfx
--add-exports javafx.graphics/com.sun.javafx.scene.text=richtextfx
--add-exports javafx.graphics/com.sun.javafx.text=richtextfx
--add-opens javafx.graphics/javafx.scene=richtextfx
--add-opens javafx.graphics/javafx.scene.text=richtextfx
--add-opens javafx.graphics/com.sun.javafx.text=richtextfx
to use VirtualizedScrollPane and reactfx component,, add in your module-info.java :
requires transitive reactfx;
requires transitive flowless;
At last I've released version 0.10.0 which is a multi-release jar that is still compatible with Java 8 but doesn't require any JVM arguments (like add-export and add-opens) when Java 9 and UP are used.
Note: this release is not modular and the JARs still need to be on the _classpath_.
Excellent work, @Jugen . Thank you.
A small gotcha/tip: If you bundle RichTextFX in an uberjar, make sure to add Multi-Release: true in your uberjar's manifest, otherwise the multi-release aspect of RichTextFX will be ignored (and you will get introspection warnings running under Java 9+).
Thanks it helped me :-)
The multi-release JAR still didn't work for me. But SkyAphid's answer did work. Thanks.
Most helpful comment
Yes, RichTextFX 0.9.x does run on Java 11 but you'll need to add the following to your main application's JAR manifest (or the equivalent to the java command line):
This won't be necessary when RichTextFX 0.10 is released (hopefully early next year 2019).