0

I have a simple javafx application, i've tried maven javafx plugin.
It seems to work, but when i try to launch the application from the command line, i get:

Exception in thread "main" java.lang.NoClassDefFoundError: javafx/application/Application

So it doesn't find javafx library. So i make sure that the jvm launched by Netbeans is the same of the jvm that i use from commandline.

This is the first line of Netbeans (7.3) debug:

cd C:\Users\agostino\Documents\NetBeansProjects\myapp; "JAVA_HOME=C:\\Program Files\\Java\\jdk1.7.0_21" "\"C:\\Program Files\\NetBeans 7.3\\java\\maven\\bin\\mvn.bat\"" "-Dexec.args=-classpath %classpath com.test.myapp.AppView -Dlog4j.debug=true" "-Dexec.executable=C:\\Program Files\\Java\\jdk1.7.0_21\\bin\\java.exe" process-classes org.codehaus.mojo:exec-maven-plugin:1.2.1:exec

and this is the test i did from commandline:

C:\Users\agostino\Documents\NetBeansProjects\myapp>java -version

java version "1.7.0_21"
Java(TM) SE Runtime Environment (build 1.7.0_21-b11)
Java HotSpot(TM) 64-Bit Server VM (build 23.21-b01, mixed mode)

Since I have just one installation of this jvm version, it must be the same.

Then what is going on here?

Is there some other test that would help me in debugging application startup?

In addition, I am very worried that when distributing javafx applications on clients, there will be a lot of such problems and that will require a lot of tuning, so I'm wondering what the best practises are.

jahroy
  • 22,322
  • 9
  • 59
  • 108
AgostinoX
  • 7,477
  • 20
  • 77
  • 137
  • Are you trying to run your app as an executable jar? If you want to distribute your app, you should consider packaging all of its dependencies inside a single jar. For some reason, NetBeans won't do this for you (Eclipse will). I use NetBeans and had to do this two days ago... The approach described in [this answer](http://stackoverflow.com/a/14879968/778118) worked perfectly. – jahroy Jun 06 '13 at 21:37

1 Answers1

1

I'm using zonski/javafx-maven-plugin, this is my setup :

<plugin>
    <groupId>com.zenjava</groupId>
    <artifactId>javafx-maven-plugin</artifactId>
    <version>1.5</version>
    <configuration>
        <mainClass>your.main.class</mainClass>
    <vendor>you.name</vendor>
    </configuration>                
</plugin>

for launching the App from the command-line :

mvn  jfx:run

for packaging to a standalone jar :

mvn jfx:build-jar

for launching the jar:

java -jar target/App-1.0-jfx.jar
Salah Eddine Taouririt
  • 24,925
  • 20
  • 60
  • 96