I started developing applications in Java + JavaFx a little over a month ago.
I was able to make a couple of beautiful animated applications. When compiling to a jar-file, I ran into the following problems:
Java17 doesn't run with jre which is for normal people, https://www.java.com/en/download/ , this begs the first question, why can't I develop on newer versions of java jdk without pain, why should I go down to version 8 and lose a lot of features
Also my javafx jars didn't want to run at all without any console messages (javafx unnamed .... @729347c ) and wouldn't run on double click. There were also messages like No runtime for favafx blah blah blah. I solved it by installing liberica jdk https://bell-sw.com/pages/downloads/#/java-17-lts. Now I can successfully compile jar files and run them by double clicking
I read right there, in a bunch of topics, that Oracle now means that I have to deliver to the clients the required version of jre (Jre17), the question is how can I do this. Newer versions of Lauch4j removed the ability to package jar along with jre. But I don't like Lauch4j either.
Later I learned about such thing as native-image in GraalVm. I tried compiling a jar file with javafx and it didn't work for me in any way. The program just crashed. And I found on the BellSoft website the package I needed https://bell-sw.com/pages/downloads/native-image-kit/#/nik-22-17, which has a configured graalvm. Thinking that these gods solved all my problems again, I compiled my jar file into an exe (yes, I changed the jdk in the environment paths). And Now I am getting Segment Fault message. But this is already better, at least it starts, although it crashes immediately after launch. Inside, by the way, the code of the usual default javafx program from Inteliji with the Hello javafx button
In general, I painted all the problems that I encountered. And I have 2 questions
- How can I distribute my javafx programs with my own jre like big companies do?
- How to compile javafx program to native-image?
My environment:
- Windows 10
- Liberica Native Image Kit 22.3.0+2 (java17 jdk)
- Latest version of Inteliji
I will also clarify that I do not want to force clients to download anything (except perhaps https://www.java.com/en/download/, but no more), I want a completely native program
Sorry if it's messy
everything I tried and did is described above