cljfx

https://github.com/cljfx/cljfx
Grigory Shepelev 2020-09-12T09:41:23.096300Z

@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...

Grigory Shepelev 2020-09-13T08:42:27.100200Z

ok. sorry for a late reply again. I just gave a developer access.

vlaaad 2020-09-13T11:26:54.100400Z

@altjsus I managed to aot-compile your example so it exits the jvm when the windows is closed, there were a couple things missing:

Grigory Shepelev 2020-09-13T11:27:20.100600Z

?

Grigory Shepelev 2020-09-13T11:27:27.100800Z

Thanks a lot

vlaaad 2020-09-13T11:27:33.101Z

hit send too early 🙂

vlaaad 2020-09-13T11:30:39.101200Z

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 🙂

vlaaad 2020-09-13T11:31:43.101400Z

cljfx.skip-javafx-initialization was added in 1.7.0 and you had 1.6.6

Grigory Shepelev 2020-09-13T11:35:24.101600Z

I will try right now

Grigory Shepelev 2020-09-13T11:49:49.101800Z

Thnx. Now it works as expected on close. I had :jvm-opts outside of :uberjar... May be that's also the problem

Grigory Shepelev 2020-09-13T11:50:03.102Z

Best lib maintainer in my life.

vlaaad 2020-09-13T12:00:23.102200Z

Haha thanks

vlaaad 2020-09-13T12:00:36.102400Z

Become my sponsor on GitHub :P

vlaaad 2020-09-13T12:00:45.102600Z

Or make your employer do that!

Grigory Shepelev 2020-09-13T12:06:35.102800Z

I'm unemployed/ I promise that I'll send one-time 20$ from my first salary.

vlaaad 2020-09-13T14:05:58.103Z

Haha, no pressure :) you are welcome!

Grigory Shepelev 2020-09-13T14:29:21.103200Z

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?

vlaaad 2020-09-13T14:33:57.103400Z

Try running it from the command line to see the exception

vlaaad 2020-09-13T14:35:40.103800Z

If you want to distribute your app, I would also recommend to look at jpackage

vlaaad 2020-09-13T14:36:03.104Z

https://github.com/cljfx/hn

vlaaad 2020-09-13T14:37:07.104300Z

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

Grigory Shepelev 2020-09-14T15:27:01.104500Z

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.

Grigory Shepelev 2020-09-14T15:27:28.104800Z

I'm a total newbie in java-related-devops.

vlaaad 2020-09-14T15:30:05.105Z

how do you run the assembled jar?

Grigory Shepelev 2020-09-14T15:31:32.105200Z

java -jar jarname.jar

vlaaad 2020-09-14T15:31:59.105400Z

do you use the -standalone.jar version built by leiningen?

Grigory Shepelev 2020-09-14T15:32:26.105600Z

yes!

Grigory Shepelev 2020-09-14T15:32:50.105800Z

That's the strange. Thing. It feels like it's not standalone.

vlaaad 2020-09-14T15:33:08.106Z

exactly what I thought

vlaaad 2020-09-14T15:33:33.106200Z

do you assemble the standalone jar on the same OS as the OS you try to run on?

vlaaad 2020-09-14T15:33:49.106400Z

e.g. do you build the windows jar on windows?

Grigory Shepelev 2020-09-14T15:35:56.106600Z

I build on ubuntu.

vlaaad 2020-09-14T15:36:13.106800Z

that’s the problem 🙂

Grigory Shepelev 2020-09-14T15:36:18.107Z

Won't that work on Win? I thought that's the goal of java....

Grigory Shepelev 2020-09-14T15:36:26.107200Z

Sheeeet

vlaaad 2020-09-14T15:36:55.107400Z

even though jar is cross-platform, this cross-platformness is only about the class files

vlaaad 2020-09-14T15:37:19.107600Z

in addition to class files, jars might contain platform-specific libraries

vlaaad 2020-09-14T15:37:28.107800Z

javafx has platform-specific libraries

Grigory Shepelev 2020-09-14T15:38:00.108Z

😞

vlaaad 2020-09-14T15:38:15.108200Z

it also configured it’s maven dependencies in a way that automatically selects the jars for the OS we resolve maven deps for

Grigory Shepelev 2020-09-14T15:38:43.108400Z

How can I set that up?

Grigory Shepelev 2020-09-14T15:39:38.108600Z

Is that possible

vlaaad 2020-09-14T15:41:12.108800Z

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

vlaaad 2020-09-14T15:41:37.109Z

we do this in Defold editor: https://github.com/defold/defold/blob/editor-dev/editor/project.clj#L81-L108

Grigory Shepelev 2020-09-14T15:58:57.109300Z

thnx

Grigory Shepelev 2020-09-14T15:59:23.109500Z

sorry for late reply

Grigory Shepelev 2020-09-14T16:00:16.109700Z

So you build them with 3rd services (github can build platform-specific, for windows)?

vlaaad 2020-09-14T16:08:13.109900Z

Yeah, GitHub has mac/windows/linux runners

Grigory Shepelev 2020-09-14T16:14:09.110100Z

Cool. I'm a retrograde

Grigory Shepelev 2020-09-14T16:41:13.110300Z

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

Grigory Shepelev 2020-09-14T16:41:25.110500Z

have a little representation at least.

vlaaad 2020-09-14T16:52:58.110700Z

That's GitHub Actions, their built-in CI

Grigory Shepelev 2020-09-14T16:57:32.111Z

Ok. Tnhx.

Grigory Shepelev 2020-09-14T16:57:54.111200Z

Do you still have some config-yaml?

Grigory Shepelev 2020-09-14T17:02:40.111400Z

file

Grigory Shepelev 2020-09-14T17:08:08.111800Z

Oh.thnx. I didn't knew that's the workflow dir on that

vlaaad 2020-09-14T17:08:28.112Z

No problem :)

vlaaad 2020-09-12T10:38:33.096400Z

Javafx runs a non-daemon thread that prevents jvm from terminating

vlaaad 2020-09-12T10:39:10.096600Z

You can set implicit exit to true to make it terminate the vm on closing the last window

vlaaad 2020-09-12T10:39:34.096800Z

This for not make sense for repl, but useful for -main

Grigory Shepelev 2020-09-12T10:43:37.097300Z

Tnhx. I will rty right now

Grigory Shepelev 2020-09-12T10:43:46.097500Z

*try

Grigory Shepelev 2020-09-12T10:49:51.097700Z

It's not helping. Should I add something to :on-close-request of stage ?

vlaaad 2020-09-12T11:03:40.097900Z

Can you share your source so I can have a look?

vlaaad 2020-09-12T11:04:30.098100Z

It's hard to know why implicit exit is not enough

Grigory Shepelev 2020-09-12T11:17:28.098300Z

I can share access to the source code in GitLab

Grigory Shepelev 2020-09-12T11:20:33.098600Z

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

vlaaad 2020-09-12T11:24:42.098800Z

Thanks! I'll try to have a look today

vlaaad 2020-09-12T11:27:50.099Z

I can't see the code though...

Grigory Shepelev 2020-09-12T12:59:03.099200Z

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

vlaaad 2020-09-12T13:09:32.099400Z

Yes, I can open the repo, but I can't see the code

vlaaad 2020-09-12T13:10:05.099600Z

Maybe guest access isn't enough?

vlaaad 2020-09-12T13:10:39.099800Z

Or you can add some permission to guest accounts... I don't know gitlab well enough :)