1

Unfortunately I have the problem that JFoenix does not run with my Java version (13). After a short research I found out that this problem probably exists for a while (link).

I don't know Java very well and I found the introduction to JFoenix very good through numerous tutorials. I also like the integration into Scene Builder. So I wanted to ask if you know a good alternative to JFoenix that is also suitable for less experienced Java developers?

If there is no alternative, would it be problematic to use Java 9? I saw here that someone is using JFoenix with JDK 13. Is there a workaround?

A456B123
  • 63
  • 2
  • 9
  • 1
    You might be able to use JFoenix with Java 13, but you'll have to use one or more `--add-opens` VM arguments. – Slaw Apr 28 '20 at 12:58
  • 1
    Many thanks for the answer At the moment it looks like this, but it does not work: --module-path D:\PATH\javafx-sdk-11.0.2\lib --add-modules javafx.controls,javafx.fxml,javafx.base,javafx.graphics,javafx.media,javafx.swing,javafx.web --add-opens javafx.base/com.sun.javafx.runtime=ALL-UNNAMED --add-opens javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED ... – A456B123 Apr 28 '20 at 13:21

1 Answers1

0

I was able to run JFoenix with java13, you need to do bit of figuring out. One more person asked a similar question just yesterday see this : https://stackoverflow.com/a/61473762/2448015

And also you can see in comments 2 people gave you the correct solution. All I can additionally contribute is give you are working example.

If you are directly running, then you just need to add the relevant vm flags such as

--module-path=D:\[YOUR DIRECTOY\javafx-sdk-13\lib
--add-modules=javafx.base, javafx.controls, javafx.fxml, javafx.graphics, javafx.media, javafx.swing, javafx.web
--add-opens
javafx.base/com.sun.javafx.runtime=ALL-UNNAMED
--add-opens
javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED
--add-opens
javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED
--add-opens
javafx.base/com.sun.javafx.binding=ALL-UNNAMED
--add-opens
javafx.base/com.sun.javafx.event=ALL-UNNAMED
--add-opens
javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED

Refer : https://github.com/jfoenixadmin/JFoenix/issues/889#issuecomment-450744122

If you are using maven, you can refer to the following :

<option>--add-opens</option>
<option>javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED</option>

In the POM configuration for the javafx-maven-plugin For this, you need to fix the pom, something like this

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>nu.sharabheshwara.A456B123</groupId>
    <artifactId>nu-sharabheshwara-A456B123-MyFx</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>11</version>
        </dependency> 
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>11</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-web</artifactId>
            <version>11</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-media</artifactId>
            <version>11</version>
        </dependency>
        <dependency>
            <groupId>com.jfoenix</groupId>
            <artifactId>jfoenix</artifactId>
            <version>9.0.1</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.4</version>
                <configuration>
                    <mainClass>application.Main</mainClass>
                    <options>
                        <option>--add-opens</option><option>javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED</option>
                        <option>--add-opens</option><option>javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED</option>
                        <option>--add-opens</option><option>javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED</option>
                        <option>--add-opens</option><option>javafx.base/com.sun.javafx.binding=ALL-UNNAMED</option>
                        <option>--add-opens</option><option>javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED</option>
                        <option>--add-opens</option><option>javafx.base/com.sun.javafx.event=ALL-UNNAMED</option>


                        <option>--add-exports</option><option>javafx.controls/com.sun.javafx.scene.control.behavior=ALL-UNNAMED</option>
                        <option>--add-exports</option><option>javafx.controls/com.sun.javafx.scene.control=ALL-UNNAMED</option>
                        <option>--add-exports</option><option>javafx.base/com.sun.javafx.binding=ALL-UNNAMED</option>
                        <option>--add-exports</option><option>javafx.graphics/com.sun.javafx.stage=ALL-UNNAMED</option>
                        <option>--add-exports</option><option>javafx.base/com.sun.javafx.event=ALL-UNNAMED</option>
                    </options>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <compilerArgs>
                        <arg>--add-opens</arg><arg>javafx.graphics/com.sun.javafx.scene=ALL-UNNAMED</arg>
                    </compilerArgs>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

To run, use the command mvn javafx:run or mvn clean javafx:run . This will use javafx-maven-client instead of apache.

If this doesn't help, you can simply check this github sample maven project where you can put your existing jfoenix code and make it work

https://github.com/shashaanktulsyan/java-javafx-maven-learning-tips/tree/master/nu-sharabheshwara-jfoenix_maven_javafx11_fix_demo

This should surely 100% solve your problem.

  • @A456B123 upload your code as is, in github or someplace, and share it, I can try to make it run. There is no other way I see. – Sri Nithya Sharabheshwarananda Apr 28 '20 at 15:12
  • 1
    Thanks for the help. I've uploaded the files to git now. If there's anything missing, feel free to let me know (haven't worked with git yet...) https://github.com/A456B123/MyFXTest/tree/master/MyFx/src – A456B123 Apr 28 '20 at 15:45
  • @A456B123 i was able to run your code. I repackaged it as a nice maven project. https://github.com/shashaanktulsyan/java-javafx-maven-learning-tips/tree/master/nu-sharabheshwara-A456B123-MyFx . There is blue background and a textfield kind of thing. – Sri Nithya Sharabheshwarananda Apr 28 '20 at 16:54
  • Many thanks for your work. :) I imported your code, but unfortunately I still get an error. Could you type something into the text field (this is a normal JavaFX text field -sorry for that - content doesn't matter), and click on "Next"? There I get the error messages. – A456B123 Apr 28 '20 at 18:52
  • A few more internal API I exported from here https://stackoverflow.com/a/53527897/2448015 And also from this we know, many features of JFoenix will not work beyond java 11.02 https://stackoverflow.com/questions/55889654/illegalaccessexception-for-jfxtextfield-with-java-sdk-12 So just I install Jdk11.02 and it worked ! I don't see any error. With this u can use gluon and make a mobile app with JFoenix. Beyond this if u want to use higher version of java, u need to drop JFoenix or the JFoenix guys really need to stop using such ugly hacks. – Sri Nithya Sharabheshwarananda Apr 28 '20 at 20:56
  • You are amazing. Now it works :). Thank you so much – A456B123 Apr 29 '20 at 06:31