Export a JavaFX project in eclipse to a runable jar

440 Views Asked by At

I need to send a project made by JavaFX SDK 16 and Java SE-15 using Eclipse to my friends, but when I try to export it, i'm getting surprised that Eclipse doesn't insert the VM arguments to the exported file : enter image description here

and as you know since JavaFX SDK 10, JavaFX libraries are not anymore part of the Java SE, so we need to tell Eclipse where to find them by VM arguments, in short words, these VM arguments are really important to run my program.

I already know that I can insert those arguments while using prompt command to open it, but is there a more simple way? just by clicking on the exported file ?

2

There are 2 best solutions below

1
On BEST ANSWER

Your main problem is that you are trying to do something that does not make any sense. Runnable jars are not a proper distribution format for JavaFX applications for various technical reasons. The way to go is having a look at jpackage. That's the proper way of dealing with distribution nowadays. Otherwise your are just banging your head against a wall.

Here is a good summary of all the options you have: https://stackoverflow.com/a/68823040/4262407

0
On

I have this problem 5 years ago (I use netbeans IDE, so I don't know if it works in eclipse, but I think yes), and I cant find a good way to do this. Instead, I created one Swing application, and put all code of JavaFX inside. You could see how I do in this link from Oracle.