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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With