-1

New to Java here. I have a java project on netbeans using maven. I am trying to add javafx to my project.

I added the following to my pom.xml file :

        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx</artifactId>
            <version>15</version>
            <type>pom</type>
        </dependency>

But when i try and build my project in netbeans I get this error (tsInfluence is the class which contains the main method that is trying to call jfx):

Error: LinkageError occurred while loading main class com.ts.tsInfluence.tsInfluence
    java.lang.ClassFormatError: Invalid superclass index 0 in class file com/ts/tsInfluence/tsInfluence
Command execution failed.
Tamjid
  • 4,326
  • 4
  • 23
  • 46

3 Answers3

0

Go to project properties -> Libraries -> Add a new classpath (Library) -> Give name etc -> than add the path to the scr zip of javafx

Edit: Doesnt a window like this appear to you? right mouse button on project name enter image description here

Edit 2: Oh right... in maven you need to follow this http://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

A similiar question was answered here... you should follow what they say and just replace the file path for yours

Question close to this

MrSano43
  • 71
  • 6
-1

The easiest way to build applications with JavaFX is to use a build of OpenJDK that includes the JavaFX modules. BellSoft and Azul both have variants of OpenJDK that bundle the JavaFX modules. Bellsoft's Liberica JDK calls this the "Full JDK", Zulu just calls it the "JDK FX" package. Beware that Bellsoft's version may not include the full media support - read the notes.

https://www.azul.com/downloads/zulu-community/?package=jdk-fx

Otherwise, follow the instructions at https://openjfx.io/openjfx-docs/#maven

swpalmer
  • 3,890
  • 2
  • 23
  • 31
-2

Your setup does not work because "javafx" is not a valid artifact id. You have to provide (possibly more than one) dependencies like this.

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>15.0.1</version>
</dependency>

For more details read the documentation: https://openjfx.io/openjfx-docs/#maven

mipa
  • 10,369
  • 2
  • 16
  • 35