0

I've coded a JavaFX project using eclipse which it's executing. However, when I try to compile the project through the command prompt, I get errors. Here's the project structure: Eclipse

Here are the errors: command prompt

I'm using jdk 15 with Javafx version 15 by gluon.

Show Command Line in Run Configurations:

C:\Users\rakes\.p2\pool\plugins\org.eclipse.justj.openjdk.hotspot.jre.full.win32.x86_64_14.0.2.v20200815-0932\jre\bin\javaw.exe --module-path "C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1h\lib" --add-modules javafx.controls,javafx.fxml -Dfile.encoding=Cp1252 -p "C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib\javafx-swt.jar;C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib\javafx.base.jar;C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib\javafx.controls.jar;C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib\javafx.fxml.jar;C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib\javafx.graphics.jar;C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib\javafx.media.jar;C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib\javafx.swing.jar;C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib\javafx.web.jar;C:\Users\rakes\.p2\pool\plugins\org.eclipse.fx.ide.css.jfx8_3.7.0.202010120832.jar" -classpath "C:\Users\rakes\Documents\York\JAVA\Coinsorter_final\CoinSorterGUI\bin" -XX:+ShowCodeDetailsInExceptionMessages application.Main

Update: executed the following commands:

set PATH_TO_FX="C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib"

javac --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml -d . Main.java

java --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml application.Main

The program seems to be compiling. However running the program gives the following error now java.lang.NullPointerException: Location is required.

loa_in_
  • 1,030
  • 9
  • 20
  • 1
    Please don't link things, but copy minimal reproducible parts of your code directly into the question. – rethab Nov 26 '20 at 15:50
  • 2
    The classpath seems not correct. In the run configuration there is a button _Show Command Line_ where you can get the classpath from which should be the same for compiling and running. – howlger Nov 26 '20 at 16:49
  • why you have added javafx-swt – Ranjit Vamadevan Nov 27 '20 at 05:22
  • @howlger : no change in classpath there – user13006302 Nov 27 '20 at 13:16
  • @user13006302 I doubt that, please add to your question what you get from the _Show Command Line_ button of a run configuration. Your `-classpath` looks odd by not containing JARs and not ending with the wildcard `*`. – howlger Nov 27 '20 at 13:38
  • @howlger: added – user13006302 Nov 27 '20 at 14:58
  • According to the command line of the run configuration it should be `-classpath C:\openjfx-15.0.1_windows-x64_bin-sdk\javafx-sdk-15.0.1\lib\*` (if using classpath only without modulepath). – howlger Nov 27 '20 at 15:59
  • @howlger made the changes. now its throwing error:java.lang.NullPointerException: Location is required. at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3316) at javafx.fxml/javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3280) – user13006302 Nov 27 '20 at 16:24
  • a) use the example helloWorld at openio to setup your context (it's guaranteed to work) b) apply what you learned to your application .. and make sure the resource lookup is correct (the error in your last comments looks like it might be wrong, see https://stackoverflow.com/questions/61531317/how-do-i-determine-the-correct-path-for-fxml-files-css-files-images-and-other) – kleopatra Nov 28 '20 at 11:18

0 Answers0