1

I have a project on netbeans and after buliding the project the jar file is generated along with lib folder but jar is not opening. When i tried to run the jar from command line, it says

Error: Could not find or load main class jewelleryinventory.JewelleryInventory
Caused by: java.lang.NoClassDefFoundError: javafx/application/Application

Any help would be good. It used to open previously but now not opening. Also i can run it from netbeans.

Shreyans jain
  • 559
  • 6
  • 18
  • Refer this. [link](https://stackoverflow.com/questions/18093928/what-does-could-not-find-or-load-main-class-mean) – UDS Jan 27 '22 at 07:12
  • See the section in the eden coding guide on [adding VM arguments to a jar](https://edencoding.com/runtime-components-error/#jar) or package another way (e.g.!jlink or jpackage). – jewelsea Jan 27 '22 at 08:31
  • 1
    For the `java` command, ensure the required JavaFX modules are on the `--module-path` *and*, if your app is *not* modular, ensure you name the required JavaFX modules in `--add-modules`. – jewelsea Jan 27 '22 at 08:49
  • @UDS the answer at that link is pretty awesome, but unfortunately it doesn’t cover Java modularity well, IMO. – jewelsea Jan 27 '22 at 09:27

1 Answers1

0

I recently installed java 11 so when i was running through cmd or double clicking it was taking java 11. When i ran through java 8. it ran successfully.

Shreyans jain
  • 559
  • 6
  • 18
  • JavaFX is no longer bundled with JDK 11. With Java 11 you need to download and install [JavaFX for Java 11](https://gluonhq.com/products/javafx/). Then add flowing to the command line `--module-path \javafx-sdk-11\lib --add-modules=javafx.controls` – Victor Gubin Jan 27 '22 at 15:36