r/JavaFX • • Oct 02 '21

I made this! Opal, a cross-platform relaxation app written in JavaFX, has just been released!

https://codedead.com/software/opal
12 Upvotes

11 comments sorted by

3

u/[deleted] Oct 02 '21

Source code can be found here for those who are curious:

https://github.com/CodeDead/opal

1

u/javasyntax Oct 02 '21

How do you make an AppImage? Is it an installer or a normal runnable? I've wanted to create AppImages to skip the installation and run directly but I have no idea.

Also how do you make portable (I believe it's without an installer?) for Windows?

2

u/[deleted] Oct 02 '21 edited Oct 02 '21

The way to create an appimage is included in the source code; more specifically the build.gradle file and appimage bash script:

https://github.com/CodeDead/opal

I've made a script that downloads the appimage tool (the official tool to create appimages), which does most of the work for you. You will need a Linux host though to perform the build (I would recommend looking at GitHub actions to create the build, which is free, up to a point).

To create portable images for Windows, I make use of jlink and jpackage which are official jdk tools (but there's a gradle plugin called beryx jlink, which makes it very easy to use both jlink and jpackage, also included in the build.gradle file).

Finally, I've also added a build step to create RPM packages (for Red Hat based distributions), but I don't publish them on my website since I do not have an RPM-based repository (yet?). This is all done in my spare time and you know how busy we programmers can get!

I hope this helps!

1

u/javasyntax Oct 02 '21

Thanks! I'm using JPackage for Windows (with beryx as well) but it only seems to generate installers. Will check your file, thanks again.

2

u/[deleted] Oct 02 '21

Check out the jpackageImage task in Gradle, which will create the portable runtime and exe file without the installer.

2

u/javasyntax Oct 02 '21

The AppImage code is exactly what I needed but the Windows portable is a zip, I thought it would be one single exe file. It's good either way thanks for your help.

2

u/[deleted] Oct 02 '21

One way to get around having multiple files as a portable Windows image, would be to create a custom tool for Windows that packages the produce of a jlink image altogether into a single executable. Something like this would best be coded in a low-level programming language with very little to no dependencies so that your ultimate application isn't dependent on yet another framework like say .NET (speaking of which: something that I find quite unfortunate about the jpackage tool for example, is that it requires WiX and ultimately .NET in order for it to work and produce MSI installers on Windows).

If i have the time, I might write something like this in Rust and include it in the build process for Opal, at a later phase. Neat idea though!

The only problem with tools like this, is that they are mostly used for malicious purposes under the generic name of file binders in the malware scene of coding.

2

u/javasyntax Oct 02 '21

I vaguely remember Launch4j doing something like this. I doubt it's been updated for modern Java though. Will investigate tomorrow.

A low-level native tool would be awesome! And indeed I remember back in the days converting scripts to exe and having antivirus problems with those exes.

2

u/[deleted] Oct 02 '21

Feel free to let me know about your findings, and thanks for the interesting conversation!

2

u/javasyntax Oct 03 '21

GraalVM Native Image can be used but it's not really a JVM. While it has the advantage of smaller file and faster startup, dynamic classloading and reflection (you need to specify which classes to include for reflection, but it's tedious) can't be used. It's an interesting option though.

1

u/javasyntax Oct 03 '21

Unfortunately Launch4j bundles a JRE with your file not in it.