Troubles with compliation of javafx project

55 Views Asked by At

So here we go.Got some problems with compilation of javafx project. I was doing whole project using VS code editor and at the end I need to compile and run it using console. And when i'm doing it by using this command i get next errors. so this classes are defined within bookingapp package but i dont use any javafx library in them and however i keep getting those errors.

D:\Vladislav_Sovostyanov_230103134\BookingApp>javac --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml src/bookingapp/App.java
src\bookingapp\App.java:12: error: cannot find symbol
    public static Consumer consumer;
                  ^
  symbol:   class Consumer
  location: class App
src\bookingapp\App.java:13: error: cannot find symbol
    public static PersonData data1;
                  ^
  symbol:   class PersonData
  location: class App
src\bookingapp\App.java:14: error: cannot find symbol
    public static PersonData data2;
                  ^
  symbol:   class PersonData
  location: class App
3 errors

i tried compiling like that javac --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml src/bookingapp/*.java all files are compiles but when i want to run it using this command java --module-path %PATH_TO_FX% --add-modules javafx.controls,javafx.fxml src/bookingapp/App it gives ClassNotFoundException while in the directory there is App.class file

1

There are 1 best solutions below

0
StM On

Your run-command searches for the main-method in src/bookingapp/App.class the other class-files need to be added to the module-path or the classpath at least (default module)

Why not packing your compiled class-files into a jar, then include the jar into the module-path and start the main-app via its fully qualified name (all packages upfront)