Error javafx runtime components are missing and are required to run this application launch4j

Include dependencies in jar #236 Comments I’m trying to include all the (openjfx) dependencies in a fat jar so it can be run without OpenJFX installed. I have successfully built a .jar file contained all the dependencies (I think), but for whatever reason I get: Error: JavaFX runtime components are missing, and are required […]

Содержание

  1. Include dependencies in jar #236
  2. Comments
  3. B4J Question JavaFX runtime components are missing
  4. amorosik
  5. Daestrum
  6. aminoacid
  7. DonManfred
  8. amorosik
  9. amorosik
  10. amorosik
  11. DonManfred
  12. aminoacid
  13. amorosik
  14. amorosik
  15. Linux Mint Forums
  16. (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»
  17. (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»
  18. Re: Java -«»Error: JavaFX runtime components are missing, and are required to run this application»
  19. Re: (Issue Identified but Unsolved) «Error: JavaFX runtime components are missing, and are required to run this applicat
  20. Re: (Issue Identified but Unsolved) «Error: JavaFX runtime components are missing, and are required to run this applicat
  21. Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»
  22. Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»
  23. Which JavaFX / openjfx versions are AVAILABLE to install. — «Error: JavaFX . «
  24. Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»
  25. Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»
  26. Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»

Include dependencies in jar #236

I’m trying to include all the (openjfx) dependencies in a fat jar so it can be run without OpenJFX installed. I have successfully built a .jar file contained all the dependencies (I think), but for whatever reason I get: Error: JavaFX runtime components are missing, and are required to run this application . I’m not sure if this is a bug or just a lack of knowledge. Either way, I think a working example could be useful.

The text was updated successfully, but these errors were encountered:

So LauncherHelper.java abort as the module javafx.graphics isn’t available and a single jar can only contain a single module (?).

So a self-contained .jar with OpenJFX seems to be unsupported at the moment?

I can try later to reproduce, but you are using Java 10, which includes JavaFX, and then adding JavaFX 11 dependencies. That looks like a bad idea.

The reason is that the Java 11 runtime will check if the main class extends javafx.application.Application, and if that is the case, it strongly requires the javafx platform to be available as a module, and not as a jar for example.
It was discussed here: http://mail.openjdk.java.net/pipermail/openjfx-dev/2018-June/021977.html

While going modular is definitely the way to go, I still think it’s unfortunate that JavaFX applications are treated a bit different here from other application (where you can still use the classpath).

There are some easy workarounds though. For example, you can have a main class that is not extending javafx.application.Application, and that main class can then call the main(String[]) method on your real main class (that way, the Java launcher doesn’t require the javafx libraries to be available as named modules).
See
https://stackoverflow.com/questions/52569724/javafx-11-create-a-jar-file-with-gradle/52571719#52571719
or https://stackoverflow.com/questions/52569724/javafx-11-create-a-jar-file-with-gradle/52615808#52615808

I can try later to reproduce, but you are using Java 10, which includes JavaFX, and then adding JavaFX 11 dependencies. That looks like a bad idea.

OpenJDK does not include OpenJFX as far as I know?

There are some easy workarounds though. For example, you can have a main class that is not extending javafx.application.Application, and that main class can then call the main(String[]) method on your real main class (that way, the Java launcher doesn’t require the javafx libraries to be available as named modules).

Thanks, now it works. Next step I need to figure out how to bundle all the native libraries (windows, mac, linux) instead of only one.

OpenJDK does not include OpenJFX as far as I know?

Only from 11. You are using Java 10, which includes JavaFX 10.

Oracle JDK 10 include JavaFX, OpenJDK 10 does not. I’m using OpenJDK 10.

Sorry, I quickly saw Java version: 10.0.2, vendor: Oracle Corporation and thought you were using Oracle JDK 10.

Источник

B4J Question JavaFX runtime components are missing

amorosik

Expert

B4J ver 9.10
Strumenti / Configura Percorsi = C:Program FilesJavajdk-11.0.1binjavac.exe
Java11+FxRuntime downloaded from B4x.com web site

When i try to start a jar with
c:programjavajdk-11-0.1binjava.exe -jar c:testtest.jar

this error appear: «Error: JavaFx runtime components are missing, and ae required to run this application»

Also using integrated Packager11 the .exe not start correctly

What is the reason of above error, and how to correct?

Daestrum

Well-Known Member

Not sure you can use Packager11 for Java 8 ( I may be wrong )

Sorry just noticed it was Windows reporting the version not the IDE.

aminoacid

Active Member

Looks like you have both Java 8 and Java 11 on your computer. Did you compile your program with 8 or 11 ? Make sure that the path to javac.exe points to the correct exe file (i.e. for Java11)

[edit]
Sorry «Strumenti / Configura Percorsi = Configure paths»] Need to brush up on my Italian

Did you download Java11+Fx from Erel’s link or elsewhere on the forum?

DonManfred

Expert

amorosik

Expert

amorosik

Expert

Looks like you have both Java 8 and Java 11 on your computer. Did you compile your program with 8 or 11 ? Make sure that the path to javac.exe points to the correct exe file (i.e. for Java11)

[edit]
Sorry «Strumenti / Configura Percorsi = Configure paths»] Need to brush up on my Italian

Did you download Java11+Fx from Erel’s link or elsewhere on the forum?

amorosik

Expert

If i try to use c:programjavajdk-1.8.0-261binjavac.exe on «Tools/Configure Path», the .jar produced run fine with
c:programjavajdk-1.8.0-261binjava.exe -jar c:testtest.jar
But integrated packager is not available
May be that some library are not compatible with java 11 ?

DonManfred

Expert

Yes, B4X IS using the configured java!!

YOU are running the command from a windows commandline. WINDOWS is deciding which to use if you do not specify a path!

The integrated packager does need Java 11 as far as i know..

aminoacid

Active Member

I now remember . I had the same problem. You HAVE to include the path to JavaFX and the required modules in the command line. Tried it on my computer:

C:javajdk-11.0.1binjava.exe —module-path C:javajdk-11.0.1javafxlib —add-modules=javafx.controls,javafx.fxml,javafx.web -jar PATH-TO-YOUR-JARFILE

Change the paths above for your setup.

In general, the command line is:

%JAVADIR%binjava.exe —module-path %JAVADIR%javafxlib —add-modules=javafx.controls,javafx.fxml,javafx.web -jar %JARFILE%

amorosik

Expert

Yes, B4X IS using the configured java!!

YOU are running the command from a windows commandline. WINDOWS is deciding which to use if you do not specify a path!

The integrated packager does need Java 11 as far as i know..

No
«..When i try to start a jar with c:programjavajdk-11-0.1binjava.exe -jar c:testtest.jar . «

Then Windows cannot decide wich Java version to start

amorosik

Expert

I now remember . I had the same problem. You HAVE to include the path to JavaFX and the required modules in the command line. Tried it on my computer:

Источник

Linux Mint Forums

Welcome to the Linux Mint forums!

(Solved) «Error: JavaFX runtime components are missing, and are required to run this application»

(Solved) «Error: JavaFX runtime components are missing, and are required to run this application»

Post by ramk » Fri Jul 26, 2019 1:07 am

Solution / Resolution — Added 12th August 2019 (12:12 Indian Standard Time) see new reply
Added on 27th July 2019 (15:15 Indian Standard Time)
Below is the original post. However the 3 reply has the correctly identified issue — am unsure if it should be a new thread or here. So am placing it in this thred

Original Post
Error 1 — while running Java

Am trying to run a Jar file related to Income Tax Filing (in india). There are different forms (hence different JAR files available)

I tried running two different forms (ITR3 and ITR 4 https://www.incometaxindiaefiling.gov.i . s?lang=eng) and both give different errors

I checked this [SOLVED] Can’t run .jar files with JavaFX while having openjfx installed viewtopic.php?f=47&t=293529&p=1631235&h . x#p1631235 but the solution there does not resolve the issue for me . However am posting some of the details asked for in that query.

I also tried different version of Java / openjdk but the error returned are the same

Other system Details provided are
1. Java Versions installed and available
2. Java /openjfx version installed and path
3. Inxi -Fxzd

Java Versions installed

Re: Java -«»Error: JavaFX runtime components are missing, and are required to run this application»

Post by ramk » Fri Jul 26, 2019 3:58 am

I ran Linux Mint 18.1 as a live session. By default it has openjdk-8-jre installed .
When I ran the .jar file it provided the same error message — however I then instaled openjfx and after that the file opened as it should.

So it seems the issue is the the later versions of openjdk (i.e beyond that for some reason are preventing the application from running smoothly

Now the questions is can i purge / remove all files related to java and just reinstall open-jdk8 and get the files work

Will let you know how this goes and after this will see if this should me marked as solved or «worked around»

Re: (Issue Identified but Unsolved) «Error: JavaFX runtime components are missing, and are required to run this applicat

Post by ramk » Sat Jul 27, 2019 7:24 am

PROBLEM IDENTIFIED
*CRUX of what seems the issue**
Tha openjdk-8 which is the selected environment is not able to «call» on the correct version of openjfx installed (which is openjfx/bionic 8u*

But am unable to resolve it.

##DETAILED##
So the original error message is

This is to run a Tax software that requires JRE (Java Runtime Environment) Version 8 with latest updates

After a lot of searching and not being able to come across a solution I tried to see if an older Linux Mint version would run the software.
So Ran a live session of Linux Mint 18.
The live session has openjdk environment installed by default. But returned the same error message as in the title.
*however* installing the default openjfx version in the available default repositories then also installed openjdk-8 (and related software) which in turn enabled the required Tax software to run.

I replicated the same in two more live sessions as well as in the latest Linux Mint 19 (Mate).

In each case the following parameters were consistent
Live Session Linux Mint 19.1

**
By default Openjdk-11 is on

then i installed openjfx which automatically installs openjdk-8

then the ITR software works

** NEXT STEP REPLICATING THIS ON THE INSTALLED 18.3 LINUX MINT**
First , I uninstalled any extra ppa’s that I had (like the webupd8 repos etc)

then using this guide https://novicestuffs.wordpress.com/2017 . rom-linux/
I uninstalled openjdk and opnjfx and manually found and deleted everything and anything to do with openjdk.

I then reinstalled openjdk-11 (and associated files)
After that installed openjfx but here it did not autoinstall openjdk-8 (and associated files)

However I still end up with the same error (as in the title)

**CRUX of what seems the issue**
Tha openjdk-8 which is the selected environment is not able to «call» on the correct version of openjfx installed (which is openjfx/bionic 8u*

Because under lve sessions it works everytime however in each case the openjfx is version openjfx/bionic 8u*

Below is the output of the current openjfx environment — and I am not unable to find how to make sure the openjfx/bionic 8u* is the selected openjfx environment

***
**WORKAROUND**
Right now the long way to get my work done is to work through a Live Session.

I thought, that maybe, doing a fresh install of an OS might work but am pretty sure that as soon as I run the first updates the software will get upgraded and the conditions will change and the software won’t work anymore.

However would like to know if its possible to resolve this on the already installed session. I guess very specifically (if the problem is identified correctly) how to make sure the correct openjfx works

Re: (Issue Identified but Unsolved) «Error: JavaFX runtime components are missing, and are required to run this applicat

Post by tagMacher » Sat Aug 10, 2019 2:39 pm

Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»

Post by ramk » Mon Aug 12, 2019 2:54 am

I just saw your reply

In the mean time I got help from a friend who is very experienced and since I was able to provide him with the exact problem it took about 5 minutes to solve.

**
The solution was eventually really simple but something I needed to learn

using apt-get -V to get the versions available

and then using the same installed the appropriate version of openjdk 8, openjfx 8 and the related «correct» dependencies.

The sequence of commands is given below

when finding that wrong versions were being installed continued to check each package

After that the Software works as required

Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»

Post by rpattabi » Fri Aug 30, 2019 3:27 am

I registered in this forum just to thank @ramk. Your detailed post saved me lot of headache while filing the returns at the last minute. Just last week, I wiped out windows. Thank you.

I wonder if there is a way we could help each other every year as I expect income tax’s dev could throw some surprises for linux users (may be due to lack of testing).

Which JavaFX / openjfx versions are AVAILABLE to install. — «Error: JavaFX . «

Post by droopy4u » Tue Jun 09, 2020 3:52 am

.
The solution was eventually really simple but something I needed to learn

using apt-get -V to get the versions available

and then using the same installed the appropriate version of openjdk 8, openjfx 8 and the related «correct» dependencies.

The sequence of commands is given below

when finding that wrong versions were being installed continued to check each package

How can I figure out which JavaFX / openjfx versions are available to install.

Your solution worked fine, but I rather would like to figure how I can define which version JavaFX / ‘ openjfx‘ is the best according the ‘java’ version, which is running on my system.

I know you wrote : by ‘ trial and error’.

So I followed your information and tried out for version ‘8u252-b09’, but without success:

Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»

Post by sanjay108 » Sun Aug 23, 2020 2:13 pm

I am a complete newbie and this is the solution which worked for me. I am using linux mint 19.3
Please let me explain

On the desktop I have ITR folder which is unzipped folder from the IT dept website, their java module file.

Downloaded jre-8u261-linux-x64.tar.gz from oracle website . I had to register to get the file.

Extracted and moved it to /usr/lib/jvm/ and then it is (For this you will need root priviliges)

Now i right clicked the ITR folder on desktop and opened it in terminal and typed this command

/usr/lib/jvm/jre1.8.0_261/bin/java -jar ITR-2_AY202021_PR1.3.jar

ITR-2_AY202021_PR1.3.jar is the respective program from the income tax dept. Yours may differ depending upon the tax return forms.

It worked and I could open the program.

(Please note you have to right click ITR-2_AY202021_PR1.3.jar and in permissions make it executable)

I hope it solves for others

Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»

Post by actinium15 » Mon Dec 28, 2020 2:46 pm

Re: (Solved) «Error: JavaFX runtime components are missing, and are required to run this application»

Post by pal2ie » Mon Mar 22, 2021 8:45 am

I just saw your reply

In the mean time I got help from a friend who is very experienced and since I was able to provide him with the exact problem it took about 5 minutes to solve.
.

Источник

If you’re not familiar with Java modules, you’re almost guaranteed to get hit with an error: “Runtime Components Are Missing”. It can be a huge frustration if you’re trying to get into JavaFX. Even if you consider yourself to be pretty Java-savvy.

One side effect of Oracle removing JavaFX from the JDK was to make it harder to get started. Honestly, JavaFX should be a very intuitive and easy to use piece of software. But this is one of the few awkward stumbling blocks that trips a lot of people up.

A “Runtime Components are Missing” error is generated by the Java Launcher. It is generated for all non-modular JavaFX projects since Java SE 9. However, it can be corrected by adding JavaFX modules, using command line arguments.

When I first came back to JavaFX after using it in Java 8, every single one of my old prototypes crashed. So if you’ve had this error don’t be disheartened. It’s a relatively easy fix.

How we’re going to fix it

The good news is there are several easy ways to fix your app. Generally, there are two situations you could be in to find this error.

  • You’re in an IDE and when you hit ‘Run’ the IDE delivers the error
  • You’ve got a JavaFX application packaged as a jar. It won’t run, but you’re smart enough to run it from the command line. Low and behold… error.

The solutions in each case can be similar, although if you can’t make your app modular you will have to apply command-line arguments both in the IDE and with your Jar.

I’ll start with launching from the IDE, because that seems natural. If you’ve got a Jar that won’t run, feel free to skip on down.

I’ll talk a little about why this is happening, because it has to do with JavaFX’s custom windowing and rendering systems. But, I completely understand if you just need those fixes, you can skip ahead to there too.

Fixing Runtime Components in the short term

This is a wildly irresponsible cowboy fix, but if you’re not looking to a long-term stable project (for example university projects or prototyping), it can be a good way to get around the issue for now.

To jury-rig the Java launch process and fool the LauncherHelper into not realising your app is an instance of a JavaFX Application, you can create a dummy class to act as an entry point to the program.

In this case, we’ll set MyLauncher as the main class for the application and the only responsibility of this class will be to launch our actual application!

package com.edencoding;
public class MyLauncher {
    public static void main(String[] args){
        MyApp.main(args);
    }
}

The benefit of this fix is that it will get rid of this error in both the IDE and with a packaged Jar. That being said, I’d really recommend checking out some of the more sustainable fixes below.

Especially in the case of an app you want to deploy in a production environment, you’ll have a much bigger job changing your application when it’s already in production.

If you’re curious as to why JavaFX needs to check that the runtime components are present, check out the drop-down below.

Why JavaFX needs ‘Runtime Components’

Java has other windowing solutions that don’t need this custom support, so why does JavaFX? Well, the Abstract Window Toolkit (AWT) has been with Java since the beginning. In that sense, it’s baked into the Java runtime. Swing, which also provides a GUI framework, is sat on top of AWT.

Swing, JavaFX uses its own custom windowing toolkit – glass – which is used in combination with prism, its graphics engine. Both of these are inside the javafx.graphics module. When JavaFX was added, the Java launcher was modified to allow JavaFX to set itself up before the application launched.

This is done inside a class called LauncherHelper, which is called whenever any class or jar is run.

As with everything in Java, it also makes sense to delegate where you can. So, when an application is launched, LauncherHelper checks whether it’s a JavaFX program, and if it is, it hands off the responsibilities to the FXLauncher, which runs some pre-flight checks and sets itself up ready to run.

In fact, the main class that the FXLauncher launches isn’t the main class of your application. In this case, FXHelper does the any setup needed before checking back in with our app.

One fix I’ll go through today short-circuits this test by jury-rigging the launch process to fool Java into thinking it’s not a JavaFX application. For small projects, that’s OK, but if you’re looking at developing a production-level or portfolio app, there are other, more sensible ways to do this.

If you’re looking for a really fast fix, though, it does the job.

Fixing JavaFX Runtime Components Issues Responsibly

A lot of these fixes aren’t a lot harder than the cowboy fix above, but they do take a little bit of understanding, or a tiny bit of patience.

in the first case, converting to modules takes a litte bit of understanding. But it’s a fix that will work in both the IDE and the Jar. If you choose to provide VM arguments manually, you’re going to need to provide these to run the Jar too – hence the patience.

1. Make your app modular

By far and away the most future-proof way to fix this error is to convert your project over to a modular one. That being said, it’s not always practical. There are plenty of libraries that currently don’t fully support java 9 modules (Apache POI is a great example)

It can also be a little intimidating if you haven’t migrated yourself across to modular projects yet.

Why convert to Modular

From Java 9 and onwards, Java has modularized. In part, it’s to give you flexibility to add modules easily to your runtime image without including a bunch of jars. But in part it’s because Oracle can no longer assume that Java will exist on every machine you might ship your code to.

A few years ago, when Java aggressively pushed the JRE with manufacturers, it was a safe bet that a JRE existed on most machines. But, nowadays this just isn’t the case. So, developers find themselves shipping their program (which might be quite small) with a 200 MB JRE.

With Java modules, you can include just the modules you need, to make a custom JRE of a much smaller size.

The price you pay for shedding up to 150 MB off the program you’ll eventually ship is that you need to specify which modules your program requires. If there isn’t an overwhelming reason why you need to stay pre-modular, I would suggest the a few lines of code (5 in this case) is more than worth it.

Adding modules

There are three things you need to add some basic modules to a simple App. Obviously, the modules you need will be guided by the modules you use in your program, but the three basic rules are:

1. Getting access to other modules
  • Whenever you want to include a module in your program, you need to use the requires keyword

Some modules use the transitive keyword to specify modules that they need, but also that you have access to as well! A good example of this is the javafx.controls module, which requires transitive javafx.graphics and javafx.base. That means your program can access javafx.graphics and javafx.base but you don’t need to include module statements for them.

If course, if you’re not using a build framework, you will still need to download the javafx.graphics and javafx.base jars or jmods for your program to work.

2. Giving reflective access to your module
  • We need to give javafx.graphics reflective access.

The JavaFX graphics module injects fields into a Controller using reflection. This is useful, because it facilitates dependency injection, but it means we need to grant reflective access. That requires the opens keyword.

3. Giving other access to your module
  • Part of the process of launching our app is to allow JavaFX to set up quickly int he background and then call our main class when it’s ready. To allow this, we need the exports keyword.

Part of that process is that the FXLauncher operates on our main class in order to launch it (check out “Why JavaFX needs Runtime Components” in the dropdown above), we need to allow that too.

3. Putting it all together

All-in-all, our module-info.java file should be in the root of our project directory and for a module called my.project, should look like this:

module my.project {
    requires javafx.fxml;
    requires javafx.controls;
    opens my.project to javafx.graphics;
    exports my.project;
}

That’s all we need. If you want more detail on adding modules to a project, check out my post on setting up a modular project with Maven.

Honestly, Java’s module system means that Java is now purpose-built to do things like add in JavaFX. For me this is the logical way to fix the project.

2. Add command-line arguments to your app

This is a pretty flexible fix, which can be done in any IDE. The caveat is that you’ll also need to provide the same arguments when running your Jar. For this to work, you’ll need to know the location of the JavaFX SDK you’ve downloaded on your machine.

I’ll go through what the parameters are first, then how to add them to your IDE. Finally, we’ll cover how to add these arguments when running your jar.

The module parameters you need to add

To fix this, we’re going to pass two sets of parameters to Java as we run our code.

1. Module Path

The first is --module-path, which is going to specify the location in our filesystem where the JavaFX jars are located. Regardless of where you’ve located it, you need to provide the address to the lib folder (this is where the jars are stored).

--module-path /path/to/javafx-sdk-14/lib
2. Modules to add

The second argument is --add-modules. This will define which modules to add to our project. For the simplest project, you’ll just need javafx.graphics. However, the basic use-case of an app with buttons (controls), FXML files and so on will require we include javafx.controls and javafx.fxml. Include these separated by a comma but no space.

--add-modules javafx.controls,javafx.fxml

Make sure you leave a space between the --module-path arguments and the --add-modules arguments or you’ll continue to see errors..

--module-path /path/to/javafx-sdk-14/lib --add-modules javafx.controls,javafx.fxml

Next, we’ll add them into the IDE run configuration.

Adding VM arguments in an IDE

The most popular are Eclipse and IntelliJ, so I’ll include some screenshots here, but this should work no matter which environment you’re developing in.

a. Eclipse

To add VM arguments in Eclipse, right click the project. Click Run as then Run Configurations. Head to the the Arguments tab and you’ll want the VM Arguments box (not the program arguments one).

VM Arguments can be added in the Eclipse IDE to fix the JavaFX's Runtime Components Are Missing error

b. IntelliJ

In IntelliJ, click the drop-down to the left of the run button, or in the menu bar, Run -> Edit Configurations. In the right-hand panel of your run configuration, specify your main class, and add VM options in the box below.

VM Arguments can be added in the IntelliJ IDE to fix the JavaFX's Runtime Components Are Missing error

And that’s it! Your program should run in the IDE.

Adding VM arguments to a Jar

If dependencies or project-constraints are stopping you from converting your project to a modular structure and rebuilding your Jar, you can still run your jar using a batch (or shell) script providing the runtime arguments to the launcher.

Batch scripts allow you to save executable commands into a plain text file to run later. What we’ll save is a combination of the java command to launch a jar (java -jar myJar.jar) with the arguments needed to specify the runtime components. So in each case, our script will run:

java -jar myJar.jar --module-path /path/to/javafx-sdk-14/lib --add-modules javafx.controls,javafx.fxml

If you don’t know how to create these files, here’s how. I’ll run through how to create both batch and shell scripts on Windows and Mac/Unix systems. In either case, we’ll be running the same command.

1. Creating a batch file

In Windows, create a file labelled launcher.bat in the same directory as your Jar file. Right click and select “edit” to edit your file.

Add the text, editing your module path so it points to the lib folder of the JavaFX SDK you have on your system, and save.

JDK — OpenJDK 11 /using Intellij IDEA/

I already added javafx dependency to my pom.xml. But My jar file doesn’t work.

I was trying to work my jar file by using that command.

java -jar cookorder.1.0.jar

But I got that error:

JavaFX runtime components are missing, and are required to run this application

How to solve that issue?

Pom.xml

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>order.application</groupId>
    <artifactId>cookorder</artifactId>
    <version>1.0</version>
    <packaging>jar</packaging>
    <name>Cook order application</name>

    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <maven.compiler.version>3.8.1</maven.compiler.version>
        <maven.shade.version>3.2.1</maven.shade.version>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    </properties>

    <dependencies>
        <!-- logging -->
        <dependency>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-simple</artifactId>
            <version>1.6.1</version>
        </dependency>

        <!-- converting -->
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.8.6</version>
        </dependency>

        <dependency>
            <groupId>org.yaml</groupId>
            <artifactId>snakeyaml</artifactId>
            <version>1.21</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-controls</artifactId>
            <version>13</version>
        </dependency>
        <dependency>
            <groupId>org.openjfx</groupId>
            <artifactId>javafx-fxml</artifactId>
            <version>13</version>
        </dependency>
        <dependency>
            <groupId>commons-codec</groupId>
            <artifactId>commons-codec</artifactId>
            <version>1.11</version>
        </dependency>
        <dependency>
            <groupId>com.oracle.ojdbc</groupId>
            <artifactId>ojdbc8</artifactId>
            <version>19.3.0.0</version>
        </dependency>

        <dependency>
            <groupId>net.sf.jasperreports</groupId>
            <artifactId>jasperreports</artifactId>
            <version>6.11.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.openjfx</groupId>
                <artifactId>javafx-maven-plugin</artifactId>
                <version>0.0.4</version>
                <configuration>
                    <mainClass>Main</mainClass>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven.compiler.version}</version>
            </plugin>
            <!-- fat jar -->
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-shade-plugin</artifactId>
                <version>${maven.shade.version}</version>
                <executions>
                    <execution>
                        <phase>package</phase>
                        <goals>
                            <goal>shade</goal>
                        </goals>
                        <configuration>
                            <filters>
                                <filter>
                                    <artifact>*:*</artifact>
                                    <excludes>
                                        <exclude>META-INF/*.SF</exclude>
                                        <exclude>META-INF/*.DSA</exclude>
                                        <exclude>META-INF/*.RSA</exclude>
                                    </excludes>
                                </filter>
                            </filters>
                            <transformers>
                                <transformer
                                        implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
                                    <mainClass>Main</mainClass>
                                </transformer>
                            </transformers>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

</project>

Добрый день. Я новичок в программировании. Моя задача — создать JAR файл из самого простого JavaFX проекта. Файл создаётся без проблем, но при попытке запустить его я получаю ошибку «Error: JavaFX runtime components are missing, and are required to run this application». Уже потрачено двое суток на попытки решить проблему. Помогите, пожалуйста.
Все настройки и процесс создания JARa можно увидеть в скриншотах.

5e7de3e203556374892216.png

5e7de3f999108791480978.png

5e7de3ff4a34d993138695.png

Создание JAR
5e7de403b509d145218597.png

5e7de41f65be5310742207.png

Результат после попытки запустить JAR.
5e7de4293bfbb852257814.png


  • Вопрос задан

    более двух лет назад

  • 20360 просмотров

Пригласить эксперта

Вот официальная статья от Intellij IDEA, как создать проект с JavaFX: https://www.jetbrains.com/help/idea/javafx.html

p.s. После установки библиотеки JavaFX нужно настроить виртуальную машину в IDEA, всё описано в статье, ничего особо сложного в этом нет.

Error: JavaFX runtime components are missing, and are required to run this application

Ответ кроится в ошибке и если погуглить, то найдете решение.

Коротко о главном — вам понадобится это https://openjfx.io/openjfx-docs/
Вы используете Java 14 версии. Начиная с (помоему) 11 версии они удалили JavaFX и она доступна в качестве отдельного модуля. Соответственно, ее банально в вашем jar’нике и нет.

А нет версии с гредлом или мавеном? Давно пересел на VsCode. Не помню, как там идейка собирает.
Нужно вербозить билд. Посмотрите, что вам идейка собирает. Должен быть какой-то лог обязательно.


  • Показать ещё
    Загружается…

09 февр. 2023, в 15:56

20000 руб./за проект

09 февр. 2023, в 15:55

75000 руб./за проект

09 февр. 2023, в 15:13

2000 руб./за проект

Минуточку внимания

2 дня ковырялся с javaFX
В итоге сделал таки свой hello-world калькулятор в виде jar файла:

Реализовал в нем сериализацию введенных данных в файл, причем дефолтный адрес расположения меняется в зависимости от OS — на linux проверял, работает нормально. Также реализовал нормальный парсинг строк, и ругань если что-то заполнено невалидно.

Столкнулся с кучей подводных камней при сборке и попытках запустить jar

В итоге, если у вас получилось собрать файл и он всего-лишь ругается на
JavaFX runtime components are missing, and are required to run this application
то остается скачать javafx sdk, и создать .bat — файл со следующим содержимым

java --module-path "ПУТЬ_К_СДК_FXjavafx-sdk-17.0.2lib" --add-modules javafx.controls,javafx.fxml -Dfile.encoding=windows-1251 -jar "ПУТЬ_К_ВАШЕМУ_JAR"

Не знаю, насколько это костыльно, но у меня не получилось иначе достичь моей конечной точки разработки, а именно: приложение должно было запускаться автономно, после даблклика по ярлыку.
Да, это получился даблклик по батнику, и запускается попутно консоль, где видно отладочную инфу, но это меня устроило.

Больше в FX лезть не планирую, мертворожденная тема.

Today We are Going To Solve Error: JavaFX runtime components are missing, and are required to run this application in Java. Here we will Discuss All Possible Solutions and How this error Occurs So let’s get started with this Article.

Contents

  • 1 How to Fix Error: JavaFX runtime components are missing, and are required to run this application Error?
    • 1.1 Solution 1 : follow the steps
  • 2 Conclusion
    • 2.1 Also Read This Solutions
  1. How to Fix Error: JavaFX runtime components are missing, and are required to run this application Error?

    To Fix Error: JavaFX runtime components are missing, and are required to run this application Error just follow the steps. You can solve this error very easily Just follow the below steps: First of all go to file and select project structure and modules.
    Then tap on Dependency and click on +, It will let you designate the directory where you have unpacked JavaFX’s “lib” folder. And you can edit this to call it JavaFX by double-clicking on the line. Then just select run and edit the configuration and add this –module-path /path/to/JavaFX/lib –add-modules=javafx.controls to VM option And at the last just set the SDK It will help you.

  2. Error: JavaFX runtime components are missing, and are required to run this application

    To Fix Error: JavaFX runtime components are missing, and are required to run this application Error just follow the steps. You can solve this error very easily Just follow the below steps: First of all go to file and select project structure and modules.
    Then tap on Dependency and click on +, It will let you designate the directory where you have unpacked JavaFX’s “lib” folder. And you can edit this to call it JavaFX by double-clicking on the line. Then just select run and edit the configuration and add this –module-path /path/to/JavaFX/lib –add-modules=javafx.controls to VM option And at the last just set the SDK It will help you.

Solution 1 : follow the steps

You can solve this error very easily Just follow the below steps:

  1. First of all go to file and select project structure and modules.
  2. Then tap on Dependency and click on +, It will let you designate the directory where you have unpacked JavaFX’s “lib” folder. And you can edit this to call it JavaFX by double-clicking on the line.
  3. Then just select run and edit the configuration and add this –module-path /path/to/JavaFX/lib –add-modules=javafx.controls to VM option
  4. And at the last just set the SDK

It will help you.

Conclusion

So these were all possible solutions to this error. I hope your error has been solved by this article. In the comments, tell us which solution worked? If you liked our article, please share it on your social media and comment on your suggestions. Thank you.

Also Read This Solutions

  • ERROR: Could not build wheels for scipy which use PEP 517 and cannot be installed directly
  • npm WARN old lockfile The package-lock.json file was created with an old version of npm
  • numpy.core._exceptions.MemoryError: Unable to allocate array with shape
  • Module not found: Error: Can’t resolve ‘react/jsx-runtime’
  • Laravel PDOException could not find driver

Понравилась статья? Поделить с друзьями:
  • Error java home is set to an invalid directory
  • Error javafx runtime components are missing and are required to run this application eclipse
  • Error java home is not defined correctly
  • Error java home environment variable is not set
  • Error java error release version 5 not supported как исправить