2 Replies - 339 Views - Last Post: 04 April 2019 - 02:57 AM Rate Topic: -----

#1 WinkyCode   User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 165
  • Joined: 23-February 11

Problem with JavaFX

Posted 03 April 2019 - 08:35 AM

God day dear follow programmer!
I am studying a course at Stockholm university with involve programming with Java and JavaFX. JavaFX is new for this course and even the teacher says he is unsure on the topic. We got a so called Hello World-program to test that JavaFX indeed worked. And yes, it worked on my computer after a while both with CMD and Eclipse. But yesterday and today it does not work. I got a error message that I have Googled. What I have done more then Googled is following:
  • I have reinstalled Eclipse
  • I have checked and dubbel-checked the search path for Java and JavaFX. Both cheacks out.
I have reinstalled Eclipse, checked and dubbel-checked the search path for Java and JavaFX. My computer is a Lenovo E540 with Windows 10 Education. Eclipse is the latest version. All the updates are done. The error code is as follow:
"Error: Could not find or load main class inlupp01.Hello
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application"
The code given by the teacher:
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.control.Label;
import javafx.scene.layout.FlowPane;
import javafx.scene.layout.Pane;
import javafx.stage.Stage;
public class Testing extends Application{

	@Override
	public void start(Stage primaryStage) {
		Pane root = new FlowPane();
		
		Label label = new Label("Det funkar!");
		root.getChildren().add(label);
		
		Scene scene = new Scene(root);
		primaryStage.setScene(scene);
		primaryStage.show();
	}
	
	
	public static void main(String[] args) {
		launch(args);
	}
}



The search result for this error on Google have lead me just to Java and not JavaFX. I have worked with this problem for at least six hour. I would ask kindly if anyone know was might be the problem?
I wish you all a great day!
Kind regards
Leopold, from Sweden.

Is This A Good Question/Topic? 0
  • +

Replies To: Problem with JavaFX

#2 g00se   User is online

  • D.I.C Lover
  • member icon

Reputation: 3627
  • View blog
  • Posts: 16,660
  • Joined: 20-September 08

Re: Problem with JavaFX

Posted 03 April 2019 - 08:46 AM

Quote

"Error: Could not find or load main class inlupp01.Hello
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application"

Has really nothing to do with the code you posted (which has an entirely different main class named)

You should arrange your environment so that you can do

javac Testing.java

then
java Testing

and you will then see that your code runs fine, as it just did for me

This post has been edited by g00se: 03 April 2019 - 08:48 AM
Reason for edit:: Clarification

Was This Post Helpful? 1
  • +
  • -

#3 WinkyCode   User is offline

  • D.I.C Head
  • member icon

Reputation: 10
  • View blog
  • Posts: 165
  • Joined: 23-February 11

Re: Problem with JavaFX

Posted 04 April 2019 - 02:57 AM

View Postg00se, on 03 April 2019 - 04:46 PM, said:

Quote

"Error: Could not find or load main class inlupp01.Hello
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application"

Has really nothing to do with the code you posted (which has an entirely different main class named)

You should arrange your environment so that you can do

javac Testing.java

then
java Testing

and you will then see that your code runs fine, as it just did for me



Hi!
Thanks for the help! I was at the workshop that my uni have every Thursday. The professor came by because he knows this JavaFX is new and the older students who are helping might not know how to do it. He solved it in one minute. In Eclipse, you must set the VM-arguments which I had forgotten to do. So the solution is Run --> Run Configurations --> Arguments. Under VM-arguments, put in --module-path "your_search_path\javafx-sdk-11.0.2\lib" --add-modules=javafx.controls,javafx.fxml".

Kind regards
Leopold, Sweden.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1