1

I have installed openjdk-8 and openjfx, but I still cannot build any Maven project containing JavaFX elements. The Netbeans linting doesn't show any error, but when I click on "Build Project" the output shows:

Failed to execute goal org.codehaus.mojo:exec-maven-plugin:1.2.1:exec (default-cli) on project javafx: Command execution failed. Process exited with an error: 1 (Exit value: 1) -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.
Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles:
[Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

Thanks for any ideas.

EDIT: Attaching pom file:

<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>javafx</groupId>
    <artifactId>javafx</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>jar</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
    </properties>
</project>

EDIT2: Debug output says:

--- exec-maven-plugin:1.2.1:exec (default-cli) @ javafx ---
Exception in thread "main" java.lang.reflect.InvocationTargetException
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at sun.launcher.LauncherHelper$FXHelper.main(LauncherHelper.java:767)
Caused by: java.lang.RuntimeException: java.lang.UnsatisfiedLinkError: com.sun.glass.ui.gtk.GtkApplication._isDisplayValid()Z
    at com.sun.javafx.tk.quantum.QuantumToolkit.startup(QuantumToolkit.java:267)
    at com.sun.javafx.application.PlatformImpl.startup(PlatformImpl.java:211)
    at com.sun.javafx.application.LauncherImpl.startToolkit(LauncherImpl.java:675)
    at com.sun.javafx.application.LauncherImpl.launchApplicationWithArgs(LauncherImpl.java:337)
    at com.sun.javafx.application.LauncherImpl.launchApplication(LauncherImpl.java:328)
    ... 5 more

and nbactions.xml: https://pastebin.com/0rGDD1Wh

Orbit09
  • 205
  • 2
  • 6
  • 13
  • Please read this: https://stackoverflow.com/questions/20077870/maven-wont-run-my-project-failed-to-execute-goal-org-codehaus-mojoexec-maven If it doesn't help you, please share you pom file – Adi Ohana Apr 21 '19 at 12:15
  • I have already read this question, but it didn't help me. I attached my pom file, but it's quite simple. – Orbit09 Apr 21 '19 at 12:20
  • please do what the build output says - Run with debug output enabled (and attach to the issue). Also interesting is the initial output printed by netbeans that shows what's being put on the cmd line. And possibly the content of nbactions.xml file. – Adi Ohana Apr 21 '19 at 12:26
  • Ran with debug output, attached it and also nbactions.xml – Orbit09 Apr 21 '19 at 12:35
  • from nbactions.xml file is the root of the problem. One cannot have both -jar and -classpath at the same time. – Adi Ohana Apr 21 '19 at 12:57
  • I can see jar only in the . How to solve the problem? – Orbit09 Apr 21 '19 at 13:01
  • what is your OS? – Adi Ohana Apr 21 '19 at 13:32
  • My OS is Ubuntu 18.04 – Orbit09 Apr 21 '19 at 13:35
  • the problem on some mixed-release version of Debian and the problem can be openjfx of Java 8 and libopenjfx-jni of Java 11, check that you have proper version of libopenjfx-jni, it should have libglass.so, which seems to be unavailable on problematic machine. – Adi Ohana Apr 21 '19 at 13:40
  • My terminal says `libopenjfx-jni is already the newest version (11.0.2+1-1~18.04.2)`. But I can't find libglass.so. Where to download it and how to install it? – Orbit09 Apr 21 '19 at 13:45
  • you should downgrade your libopenjfx-jni to match with your openjdk version (8). You can use https://pkgs.org/download/libopenjfx-jni to download the correct version. You can also try using openjdk 11 if it is applicable for you – Adi Ohana Apr 21 '19 at 13:56
  • Okay, I tried installing libopenjfx-jni-8 from the link, but the output still says `Failed to execute goal...` I could try upgrading openjdk to version 11, will it work with openjfx? – Orbit09 Apr 21 '19 at 14:05
  • I installed openjdk-11, which is defaultly installed by `sudo apt-get install default-jdk`. Does Netbeans 8.2 support openjdk-11? – Orbit09 Apr 21 '19 at 14:21
  • looks like it doesn't: https://stackoverflow.com/questions/52246826/cant-create-project-on-netbeans-8-2-with-jdk-10 . My suggestion is to try downgrade libopenjfx-jni to the one compatible with JDK8 – Adi Ohana Apr 21 '19 at 14:26
  • Now I have openjdk version 8 and libopenjfx-jni version 8. I'm able to build the project, but not run it. The error output is still the same: Failed to execute... – Orbit09 Apr 21 '19 at 15:18
  • Ok we are getting there. How do you run the project? With maven? And, what is the stack trace now? – Adi Ohana Apr 21 '19 at 15:22
  • I'm running the project in Netbeans - either Run Project or Run File. The full output is here: https://pastebin.com/mqTYCvxP – Orbit09 Apr 21 '19 at 15:36
  • looks like a functional error - something in your Application. not related to the openjdk or JavaFX – Adi Ohana Apr 21 '19 at 15:39
  • No javafx application works in my computer currently. The applications work on another machines. – Orbit09 Apr 21 '19 at 15:43
  • Got it. According to the above stacktrace you shared, the error now is something with your App. Try to look in https://stackoverflow.com/questions/16990482/java-lang-illegalargumentexception-invalid-url-or-resource-not-found – Adi Ohana Apr 21 '19 at 15:46
  • My app is quite simple and works on other machines https://pastebin.com/Zycbbx7L – Orbit09 Apr 21 '19 at 16:32
  • according the stack trace and the app you provided, there is no file named "hero.png" in your root classpath. try to change the path for the file – Adi Ohana Apr 21 '19 at 16:37
  • The file is in either src/main/resources or in root folder. If I remove the lines with the file, the program still won't run. – Orbit09 Apr 21 '19 at 16:44

0 Answers0