-1

I am starting my education with JavaFX, so I have created a sample JavaFX app, it contains two methods - a start(Stage primaryStage) {} method with some code I created, and a main method looking like this:

/**
 * @param args the command line arguments
 */
public static void main(String[] args) {
    launch(args);
}

When I'm trying to run the app from Netbeans - everything is allright, I can see the app, and use the buttons with implemented functionalities. BUT when I'm trying to compile and run it from the console:

C:\Users\xxx\Documents\NetBeansProjects\JavaFXApplication1\src\javafxapplication1>javac JavaFXApplication1.java

C:\Users\xxx\Documents\NetBeansProjects\JavaFXApplication1\src\javafxapplication1>dir
 Volume in drive C is Windows
 Volume Serial Number is xxx

 Directory of C:\Users\xxx\Documents\NetBeansProjects\JavaFXApplication1\src\javafxapplication1

15.01.2019  11:56    <DIR>          .
15.01.2019  11:56    <DIR>          ..
15.01.2019  11:59             1 809 JavaFXApplication1.class
15.01.2019  11:23             1 212 JavaFXApplication1.java
               2 File(s)          3 021 bytes
               2 Dir(s)  160 401 707 008 bytes free

C:\Users\xxx\Documents\NetBeansProjects\JavaFXApplication1\src\javafxapplication1>java JavaFXApplication1

I get an error:

Error: Could not find or load main class JavaFXApplication1

Am I missing something? The main method is present...

hc0re
  • 1,806
  • 2
  • 26
  • 61
  • 1
    have you tried with com.package.Testclass.java instead of com/package/testclass.java in cmd. Please visit this url-https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean – Kandy Jan 15 '19 at 11:18
  • @Kandy - I have tried `java javafxapplication1.JavaFXApplication1` from the `src` folder - and it worked. – hc0re Jan 15 '19 at 11:22
  • Then I think your issue resolved now. – Kandy Jan 15 '19 at 11:25

1 Answers1

0

Basing on @Kandy suggestion in his comment, I went one catalogue up, to src, and I have run java javafxapplication1.JavaFXApplication1 - and it worked flawlessly, so I had to run the app from the package level.

hc0re
  • 1,806
  • 2
  • 26
  • 61