Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RichTextFX with Java 11 ? #776

Closed
goxr3plus opened this issue Sep 24, 2018 · 14 comments
Closed

RichTextFX with Java 11 ? #776

goxr3plus opened this issue Sep 24, 2018 · 14 comments

Comments

@goxr3plus
Copy link
Collaborator

Can we successfully run RichTextFX with Java 11 ? If not what steps we can take to make it happen ?

@Jugen
Copy link
Collaborator

Jugen commented Nov 5, 2018

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).

@goxr3plus
Copy link
Collaborator Author

@Jugen You think we can make this project modular :) I just jumped to Java 11 and learning about modularization .

@Jugen
Copy link
Collaborator

Jugen commented Nov 9, 2018

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.

@duncanmak
Copy link

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

@Adyel
Copy link

Adyel commented Jan 12, 2019

@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.

@duncanmak
Copy link

@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

@SkyAphid
Copy link
Contributor

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

@Ry0kugin
Copy link

Ry0kugin commented Mar 9, 2019

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

@jmturc
Copy link

jmturc commented Apr 16, 2019

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

@jmturc
Copy link

jmturc commented Apr 17, 2019

to use VirtualizedScrollPane and reactfx component,, add in your module-info.java :

	requires transitive reactfx;
	requires transitive flowless;

@Jugen
Copy link
Collaborator

Jugen commented Apr 18, 2019

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.

@Jugen Jugen closed this as completed Apr 18, 2019
@terjedahl
Copy link
Contributor

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+).

@lreneral
Copy link

Thanks it helped me :-)

@pshdev0
Copy link

pshdev0 commented Oct 29, 2020

The multi-release JAR still didn't work for me. But SkyAphid's answer did work. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants