#Can't make a working jar with JavaFX (Maven)

1 messages · Page 1 of 1 (latest)

hazy smelt
#

Runs perfectly fine without any VM options inside IntelliJ but when I export it via artifact system and run it with terminal it says Error: JavaFX runtime components are missing, and are required to run this application
Did I miss something important?
This could only mean that the jar can't find the JavaFX dependencies correctly or they are not even exported.

alpine quarryBOT
#

<@&987246487241105418> please have a look, thanks.

jade ibex
#

@hazy smelt So you might need to build a JVM which includes JFX into it. I forget what it's called or whatever, but it's pretty easy to do. I did it a few months ago. You can also use jpackage I believe to pack that JVM build with your application as an EXE or other runnable file types.

#

Or at the very least, specify the location of your JFX modules in your args when running the jar.

desert rampart
#

You could for example use maven-shade-plugin to include it.

jade ibex
#

That too.

#

All of those options work.

hazy smelt
jade ibex
#

IntelliJ just runs the compiled jar with a super long command. You can do the same thing without intelliJ.

#

When you add VM args or program args, that's what it's doing. Just adding what you told it, to the command it's running on the JAR.

hazy smelt
jade ibex
#

But Simon probably has the better idea tbh. The annoying part is it usually says JFX loaded an unnamed module or something. I'm not sure how to fix it. Runs fine, just a minor annoyance.

#

If you're gonna go the command line way, take a look at this.

#

"C:\Program Files\Java\jdk-18.0.1.1\bin\java.exe" --module-path "C:\Program Files\Java\javafx\javafx-sdk-19\lib" --add-modules javafx.controls,javafx.fxml,javafx.swing -Dfile.encoding=windows-1252 -jar C:\work\system\NahjolFasahe\target\setup.jar

#

That's how you'd do it.

hazy smelt
#
``` This is mine xd
jade ibex
#

And I was mistaken, it's JLink that creates the mixed SDK.

#

Yeah, so you need a command that includes --module-path and --add-modules outside of IntelliJ.

hazy smelt
#

Yeah and how do I do that exactly?

jade ibex
#

Oh boy.. Well module path is the path to where the jfx module jars are stored.

#

So you need to find that and specify it appropriately.

#

Then add modules is all of the modules you're using from JFX.

hazy smelt
#

I understand that but how is that info being exported with jar?

#

I did that and I get this now

desert rampart
hazy smelt
#

There's nothing on adding javafx to the existing project

#

That's why I am having these issues

#

My project is originally set as java maven project and that's all

#

I didn't use archetype

#

I made a whole new projects and still can't get it working.

#

I fixed this and still when I do like maven clean install it doesn run

desert rampart
#

And there are linked repositories.

hazy smelt
#

I tried it rn

#

--module-path "C:\Users\Vasilije\Desktop\javafx-sdk-23.0.1\lib;E:\IntelliJ Projects\Other\BalkanBuyV2\target\classes" --add-modules javafx.controls,javafx.fxml In my VM Options

#

I included everything.

#

This is jar created from mvn clean install

#

and using maven-shade plugin

#

I get this running mvn shade:shade

#

I guess I'll do just java swing app then, this literally can't be done it is really badly designed

hazy smelt
#

Maven Shade plugin literally included everything javafx has to offer and I still have the missing error?

#

I needed 100 years to understand that shade is uncompatible with exporting javafx

#

It works now, I used maven-assembly-plugin.

jade ibex
#

@hazy smelt Those arguments would go in your command to run the jar OUTSIDE of IntelliJ.

#

It should be running fine in IntelliJ..

hazy smelt
#

Actually intellij is weiird