@vlaaad I had to add {:aot :all :injections [(javafx.application.Platform/exit)]}
to my uberjar
properties in project. But now I have another problem. For some reason the process is not terminating after closing the window. I still can see it in my htop...
ok. sorry for a late reply again. I just gave a developer access.
@altjsus I managed to aot-compile your example so it exits the jvm when the windows is closed, there were a couple things missing:
?
Thanks a lot
hit send too early 🙂
1. in the main ns I added this to ns form:
(:import [javafx.application Platform])
(:gen-class)
2. in the -main
fn in main ns I added (Platform/setImplicitExit true)
3. in project.clj
, I added this to :uberjar
profile:
:jvm-opts ["-Dcljfx.skip-javafx-initialization=true"]
4. I removed ^:skip-aot
from project.clj
5. I bumped cljfx version to latest (1.7.9). It is very important for aot because skipping cljfx initialization was added in a later version than what you had specified 🙂cljfx.skip-javafx-initialization
was added in 1.7.0 and you had 1.6.6
I will try right now
Thnx. Now it works as expected on close. I had :jvm-opts outside of :uberjar... May be that's also the problem
Best lib maintainer in my life.
Haha thanks
Become my sponsor on GitHub :P
Or make your employer do that!
I'm unemployed/ I promise that I'll send one-time 20$ from my first salary.
Haha, no pressure :) you are welcome!
I have one more question. It might be out of your competence. When I pack it with uberjar and run on Windows I see the exception: "A java exception has occured". And that's all basically. Nothing more. Is it connected to cljfx?
Try running it from the command line to see the exception
If you want to distribute your app, I would also recommend to look at jpackage
This example app doesn't use leiningen, but the jpackage part of the packaging is independent from the build tool, i.e. it works on uberjar
when i run it on windows cli I have:
"Graphics Device initialization failed for : d3d, sw" Problem
Exception. It seems to be connected to this (https://stackoverflow.com/questions/55561986/how-to-solve-the-graphics-device-initialization-failed-for-d3d-sw-problem) question.I'm a total newbie in java-related-devops.
how do you run the assembled jar?
java -jar jarname.jar
do you use the -standalone.jar
version built by leiningen?
yes!
That's the strange. Thing. It feels like it's not standalone.
exactly what I thought
do you assemble the standalone jar on the same OS as the OS you try to run on?
e.g. do you build the windows jar on windows?
I build on ubuntu.
that’s the problem 🙂
Won't that work on Win? I thought that's the goal of java....
Sheeeet
even though jar is cross-platform, this cross-platformness is only about the class files
in addition to class files, jars might contain platform-specific libraries
javafx has platform-specific libraries
😞
it also configured it’s maven dependencies in a way that automatically selects the jars for the OS we resolve maven deps for
How can I set that up?
Is that possible
there are 2 ways around: 1. make sure you build jars for different platforms on different platforms. Example hacker news app I posted earlier has example of github actions that do it. Perhaps gitlab has similar infrastructure you can use? 2. force maven to include dependencies for all platforms. this means you will have a really fat jar that has platform-specific libraries for every platform. You do this by specifying ALL javafx classifiers as dependencies
we do this in Defold editor: https://github.com/defold/defold/blob/editor-dev/editor/project.clj#L81-L108
thnx
sorry for late reply
So you build them with 3rd services (github can build platform-specific, for windows)?
Yeah, GitHub has mac/windows/linux runners
Cool. I'm a retrograde
I can see that's kinda complicated stuff with a lot of yaml... Are you using CircleCI? Could you please share a piece of that code? So I
have a little representation at least.
That's GitHub Actions, their built-in CI
Ok. Tnhx.
Do you still have some config-yaml?
file
Oh.thnx. I didn't knew that's the workflow dir on that
No problem :)
Javafx runs a non-daemon thread that prevents jvm from terminating
You can set implicit exit to true to make it terminate the vm on closing the last window
This for not make sense for repl, but useful for -main
Tnhx. I will rty right now
*try
It's not helping. Should I add something to :on-close-request of stage ?
Can you share your source so I can have a look?
It's hard to know why implicit exit is not enough
I can share access to the source code in GitLab
I gave an access with <mailto:v.proczenko@gmail.com|v.proczenko@gmail.com> You should see an invite. All the code in pdf-only-export
branch, in gui.clj
and app.clj
file
Thanks! I'll try to have a look today
I can't see the code though...
Do you mean you can't see code on gitlab? I have guest access Sorry for late reply... For some reason I can't see notifications on phone
Yes, I can open the repo, but I can't see the code
Maybe guest access isn't enough?
Or you can add some permission to guest accounts... I don't know gitlab well enough :)