openjfx / openjfx-docs

Getting started guide for JavaFX 11
BSD 3-Clause "New" or "Revised" License
96 stars 25 forks source link

windows command line issue #176

Open Michael-S-de opened 3 years ago

Michael-S-de commented 3 years ago

I followed the "Getting Started with JavaFX" instructions: I loaded down hellofx.java from GitHub, put it to D:\java I've set the Path_To_FX. The command javac --module-path "%PATH_TO_FX%" --add-modules javafx.controls HelloFX.java (with "" around Path_To_FX) works and I get HelloFX.class

The next step fails:

D:\java>java --module-path "%PATH_TO_FX%" --add-modules javafx.controls HelloFX
Error: Could not find or load main class HelloFX
Caused by: java.lang.ClassNotFoundException: HelloFX

All running on Windows 10. Any suggestions?

samuelstein commented 3 years ago

Do you tried it with CMD or Powershell? The commands worked for me properly under CMD.

Michael-S-de commented 3 years ago

I go a step back, dealing with the start of java programms. I startet with the easiest HelloWorld.java - without FX and without package, stored under D:\java/ :

public class HelloWorld
{
    public static void main(String args[]) {
         System.out.println("Hello, World!");
    }
}

From D:\java
with javac HelloWorld.java I get HelloWorld.class then with java HelloWorld I get Error: Coult not find or load main class Helloworld with java -cp /java HelloWorld voila: Hello, World!

Next Step with package, also in java/ :

package test_project;
public class TestProject{
    public static void main(String[] args){
        System.out.println("Test Project"); 
    }
}

javac TestProject.java gives TestProject.class

Now I have to move this TestProject.class in the Folder /test_project ! test_project is the name of the package with java -cp /java test_project/TestProject I get it runnig : Test Project

Finaly HelloFX starting in D:\java - place of HelloFX.java javac --module-path "C:\Program Files\Java\javafx-sdk-15.0.1\lib" --add-modules javafx.controls,javafx.fxml HelloFX.java gives HelloFX.class moving to /hellofx ! hellofx = packagename

java -cp /java hellofx/HelloFX crashes ... Could not find ...

NoClassDeffoundError javafx/application/Application

java -cp /java --module-path "C:\Program Files\Java\javafx-sdk-15.0.1\lib" --add-modules javafx.controls,javafx.fxml hellofx/HelloFX crashes .... Missing JavaFX application class hellofx/HelloFX

With Netbeans (12.1) I can build helloFX-Programms getting helloFX.jar Starting in the path of helloFX.jar (.../target) with Commandline it starts with java -jar --module-path "C:\Program Files\Java\javafx-sdk-15.0.1\lib" --add-modules javafx.controls,javafx.fxml helloFX.jar opening a windows with a click-Button.