0

The problem is that I have my project in netbeans and I run it and it runs without problems, I click clean and generate project but when I run the .jar it doesn't run.

I run this command in the console: java -jar HuellaTorniquete.jar

And I get this error Error: JavaFX runtime components are missing, and are required to run this application

and I run this command: java --module-path "C:\Users\crist\Documents\jjavafx\javafx-sdk-23.0.1\lib" --add-modules javafx.controls,javafx.fxml,javafx.media -jar HuellaTorniquete.jar

and it opens the .jar,

Why doesn't the .jar open from the file when I double click it? I have the fx libraries in my project and when I run it in netbeans it runs without problems

I created an .exe from the .jar and consequently it does not open.

Can anyone help?

5
  • It looks like the JRE you have installed on your system is different from the JDK you're using in Netbeans. In your JDK, JavaFX seems to be included, while in the JRE it is not. You could a) install another JRE, or b) copy the JavaFX libs into your JRE's folders, or c) include the JavaFX stuff in your .jar , or d) make your app download the JavaFX libraries from a server, before accessing the JavaFX content, but this is a bit challenging.
    – JayC667
    Commented Oct 25 at 22:38
  • Or e) Have another java app start first to make sure the JavaFX components are available, or download them, then launch your main app with the right parameters...
    – JayC667
    Commented Oct 25 at 22:41
  • Is this an ant project, for example, or a maven project, for example?
    – trashgod
    Commented Oct 25 at 22:50
  • 2
    See my comment here. Also check out these similar questions: google.com/…
    – Slaw
    Commented Oct 25 at 23:10
  • This repository demonstrates how it's done in a non modular way. Just download it and alter it to your needs: github.com/davidweber411/javafx-JavaFxAppMavenNonModular (Note: on this git account are versions using gradle and/or spring boot too). Commented Oct 29 at 6:38

1 Answer 1

0

if you want the jar to open without VM parameter, you need to bundle javaFX in it, you can do that by adding dependencies in your pom.xml file if your using maven :

<properties>
  <openjfxVersion>21.0.2</openjfxVersion>
</properties>

 <dependency>
       <groupId>org.openjfx</groupId>
       <artifactId>javafx-base</artifactId>
       <version>${openjfxVersion}</version>
       <classifier>win</classifier>
 </dependency>

You can add the same dependency for other javafx package like: javafx.controls,javafx.fxml,javafx.media

(sorry for my english)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.