JFXtras ClassNotFoundException on maven build

476 views Asked by At

I am using Eclipse with the Maven integration and included JFXtras in my project. When I do the maven build, it successfully creates the jar, but when I try to run it, I get a

java.lang.ClassNotFoundException: jfxtras.scene.control.ListSpinner

I integrated jfxtras like described here: http://mvnrepository.com/artifact/org.jfxtras/jfxtras-labs/8.0-r3

Edit:

<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>propgr</groupId>
  <artifactId>Project</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
  <dependency>
    <groupId>org.jfxtras</groupId>
    <artifactId>jfxtras-labs</artifactId>
    <version>8.0-r1</version>
</dependency>
<dependency>
    <groupId>org.jfxtras</groupId>
    <artifactId>jfxtras-controls</artifactId>
    <version>8.0-r1</version>
</dependency>
<dependency>
    <groupId>org.jfxtras</groupId>
    <artifactId>jfxtras-common</artifactId>
    <version>8.0-r1</version>
</dependency>

</dependencies>
  <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <configuration>
                    <archive>
                        <manifest>
                            <mainClass>main.Main</mainClass>
                        </manifest>
                    </archive>
                </configuration>
            </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>
</project>

Any ideas / help?

1

There are 1 answers

3
tbeernot On

JFXtras consist of a number of artifact; labs, controls, common, ..., with some dependencies between them. The dependency for labs is missing. The pom below works for me.

<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>propgr</groupId>
    <artifactId>Project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.jfxtras</groupId>
            <artifactId>jfxtras-labs</artifactId>
            <version>8.0-r3</version>
        </dependency>
    </dependencies>
    <build>
        ...
   </build>
</project>

That is for a release, if you want to use a snapshot, you need to add the Sonatype snapshot repository in the pom or .m2/settings.xml

<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>propgr</groupId>
    <artifactId>Project</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <dependency>
            <groupId>org.jfxtras</groupId>
            <artifactId>jfxtras-labs</artifactId>
            <version>8.0-r4-SNAPSHOT</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>oss-sonatype</id>
            <name>oss-sonatype</name>
            <url>https://oss.sonatype.org/content/repositories/snapshots/</url>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository>
    </repositories>
    <build>
        ...
   </build>
</project>