5

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.

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

You've uncovered a bug in Java8 and JavaFX integration - running an identical case without javaFX allows the slash '/', instead of the explicit dot '.'
0

Maybe, your problem it's that JFXHelloWorld it's extending from Application and you aren't setting the classpath correctly. Are you using Java8 or any previous Java release?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.