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

Use JAVAFX_HOME to locate java executable #86

Closed
delanym opened this issue May 21, 2024 · 4 comments
Closed

Use JAVAFX_HOME to locate java executable #86

delanym opened this issue May 21, 2024 · 4 comments
Labels
duplicate This issue or pull request already exists

Comments

@delanym
Copy link

delanym commented May 21, 2024

Hi. I ran pmd v7.1.0 and was told missing JAVAFX_HOME.
I set the env var and ran it again and was told No java executable found in PATH
If pmd is going to depend on an env var for locating the JDK then it should search for Java from there, not the path.

@delanym
Copy link
Author

delanym commented May 21, 2024

With zulu22.30.13-ca-fx-jdk22.0.1-linux_x64, after running export PATH=$PATH:$JAVAFX_HOME and trying again I get

PMD Rule Designer 7.0.0 (with PMD 7.1.0) initializing... 
Exception in Application start method
java.lang.RuntimeException: Exception in Application start method
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.launchApplication1(LauncherImpl.java:893)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication$2(LauncherImpl.java:196)
        at java.base/java.lang.Thread.run(Thread.java:1570)
Caused by: java.lang.IllegalAccessError: class net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil (in unnamed module @0xe02f64) cannot access class com.sun.javafx.fxml.builder.ProxyBuilder (in module javafx.fxml) because module javafx.fxml does not export com.sun.javafx.fxml.builder to unnamed module @0xe02f64
        at net.sourceforge.pmd.util.fxdesigner.util.DesignerUtil.lambda$customBuilderFactory$16(DesignerUtil.java:403)
        at javafx.fxml/javafx.fxml.FXMLLoader$InstanceDeclarationElement.constructValue(FXMLLoader.java:1013)
        at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:759)
        at javafx.fxml/javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2858)
        at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2654)
        at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2568)
        at javafx.fxml/javafx.fxml.FXMLLoader$IncludeElement.constructValue(FXMLLoader.java:1160)
        at javafx.fxml/javafx.fxml.FXMLLoader$ValueElement.processStartElement(FXMLLoader.java:759)
        at javafx.fxml/javafx.fxml.FXMLLoader.processStartElement(FXMLLoader.java:2858)
        at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2654)
        at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2568)
        at javafx.fxml/javafx.fxml.FXMLLoader.load(FXMLLoader.java:2536)
        at net.sourceforge.pmd.util.fxdesigner.Designer.start(Designer.java:111)
        at net.sourceforge.pmd.util.fxdesigner.Designer.start(Designer.java:64)
        at javafx.graphics/com.sun.javafx.application.LauncherImpl.lambda$launchApplication1$9(LauncherImpl.java:839)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runAndWait$12(PlatformImpl.java:483)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$10(PlatformImpl.java:456)
        at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
        at javafx.graphics/com.sun.javafx.application.PlatformImpl.lambda$runLater$11(PlatformImpl.java:455)
        at javafx.graphics/com.sun.glass.ui.InvokeLaterDispatcher$Future.run(InvokeLaterDispatcher.java:95)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication._runLoop(Native Method)
        at javafx.graphics/com.sun.glass.ui.gtk.GtkApplication.lambda$runLoop$10(GtkApplication.java:264)

@adangel
Copy link
Member

adangel commented May 23, 2024

I'm moving this issue to pmd/pmd-designer, as this is about running the PMD Designer and not PMD itself.

@adangel adangel transferred this issue from pmd/pmd May 23, 2024
@adangel
Copy link
Member

adangel commented May 23, 2024

@delanym Please refer to https://docs.pmd-code.org/latest/pmd_userdocs_extending_designer_reference.html for how to setup JAVAFX_HOME.

Currently, we either support Oracle Java 8 (which includes javafx and predates java modules) or we support any OpenJDK without JavaFX + separate JavaFX (pointed to with JAVAFX_HOME).

The zulu builds of openjdk+javafx have integrated JavaFX as a module, which we don't support yet. I think, this is essentially the problem described in #71 - which I'll rename now.

For your problem at hand: java is always used from the path (we don't use any special env var there). So make sure, your PATH contains the java version you want to use (either Java 8 or any Java-Only OpenJDK distribution will do). JavaFX (which is something different than Java) is searched from JAVAFX_HOME - you'll need to download that separately from https://gluonhq.com/products/javafx/ (the SDK variant), extract it somewhere and point JAVAFX_HOME to the directory.

E.g.

$ echo $JAVAFX_HOME
/home/andreas/programs/openjdk/javafx-sdk-17.0.8
$ ls $JAVAFX_HOME
legal  lib  src.zip

I'm closing this as a duplicate of #71.

@adangel adangel closed this as not planned Won't fix, can't repro, duplicate, stale May 23, 2024
@adangel adangel added the duplicate This issue or pull request already exists label May 23, 2024
@delanym
Copy link
Author

delanym commented May 23, 2024

Thanks. I get a warning WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @6ce2b319' but I can use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

2 participants