Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using JavaFX with packages generates "Missing JavaFX application class" error

I'm working on getting started with JavaFX now that it comes with Java 8 and I've run into a strange issue. When running from the default package, my simple Hello World application runs just fine. However, when putting it into a package, trying to run the program gives me the following error:

Missing JavaFX application class view/JFXHelloWorld

I've included a normal HelloWorld.java file in the view folder and it works just fine.

To clarify, my file structure looks like this:

jfx ----src --------view ------------HelloWorld.java ------------JFXHelloWorld.java ----target --------view ------------HelloWorld.class ------------JFXHelloWorld.class

Where target is the folder that I am putting the compiled files into with the following command:

javac -d target src/view/*.java

Running the normal HelloWorld.java file works just fine:

java -cp target view/HelloWorld Hello, World!

However, running the JavaFX file causes a problem with the ClassLoader:

java -cp target view/JFXHelloWorld Missing JavaFX application class view/JFXHelloWorld

Googling led me to 9 results, all of which are the source code for the JavaFX ClassLoader.

Both HelloWorld.java and JFXHelloWorld.java are declared to be in package view; - is this correct? Any help would be appreciated.

like image 487
AaronFriesen Avatar asked Apr 13 '14 04:04

AaronFriesen


1 Answers

My problem actually was in the command-line call to run HelloWorld.

I should instead be calling the following:

java -cp target view.HelloWorld
java -cp target view.JFXHelloWorld

For some reason, it allows you to run view/HelloWorld when it shouldn't.

like image 50
AaronFriesen Avatar answered Sep 27 '22 20:09

AaronFriesen