在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):wiverson/maven-jpackage-template开源软件地址(OpenSource Url):https://github.com/wiverson/maven-jpackage-template开源编程语言(OpenSource Language):Java 94.5%开源软件介绍(OpenSource Introduction):Java + Maven + GitHub Actions = Native Desktop AppsJavaFX or Swing + jpackage + Maven template project for generating native desktop applications. Goal
OverviewThis template uses a Maven plugin to generate a custom JVM and installer package for a JavaFX application. It can easily be adapted to work with Swing instead. Requirements
The project includes GitHub Actions which automatically generate macOS, Windows, and Linux installers. The generated installers come in at around 30-40mb. The example source in the project includes demonstrations of several native desktop features - for example, drag-and-drop from the Finder/Explorer, as well as a few macOS Dock integration examples. Removing the code and the demonstration dependencies gets a "Hello World" build size closer to 30mb than 40mb. Key FeaturesHere are few cool things in this template:
Once you get started, you might find these lists of tutorials, tools, libraries for JavaFX and general Java desktop integration helpful. Version NumberingUsually you want a "marketing version" of an app as released to customers, and a "developer version" for use in internal testing. For example, to the end user it's just "Windows 11" but there are countless build numbers for all the different versions of Windows 11. The end-user value is set in the pom.xml as If you look in the Does this work with Apple Silicon aka M1?Yes, although as of this writing I don't believe there are GitHub Action runners that support M1. But building locally on my M1 laptop works great and generates native M1 builds. I downloaded the macOS release and it won't open - the Finder says it's damaged!Yup, it's quarantined because it's not signed. You can override the quarantine via a command-line option. See the next Q on macOS signing, notarization, and stapling. Does this support macOS signing, notarization, and stapling?Yes, there is a GitHub Action and a Maven profile to assist with setting all of this up for macOS applications. For more information, see the documentation on getting macOS signing/notarization/stapling set up. It won't work out of the box, as you need to sign up for an Apple Developer account, add a bunch of GitHub Secrets and update the pom.xml. What about Linux?The JavaFX builds include several other architectures, including aarch64 and arm32. In theory, you should be able to add those just like the other builds. Haven't tested it though. Feel free to post in the discussion section if you are using Linux. Can I Use this with Swing instead of JavaFX?tl;dr absolutely. It's actually a lot easier to use Swing instead of JavaFX, as Swing is built in to the JDK and doesn't require fiddling with Java modules. Just delete the JavaFX stuff, including the JavaFX modules and add a Swing main class instead. If you are reasonably familiar with Maven this shouldn't be very hard to do. I highly recommend the FlatLaf as a must use with Swing. That look-and-feel plus designers such as the IntelliJ GUI Designer or JFormDesigner can work very well, arguably with an easier learning curve than JavaFX. In particular, delete the following directories:
Changes to the pom.xml:
UsageOnce everything is installed (see below) it's really easy to use: To generate an installer, just run...
To do everything up until the actual installer generation (including generating the custom JVM)...
Installation
Because these builds use stripped down JVM images, the generated installers are in the 30-40mb range. On macOS you should add signing to avoid error messages related to the security system(s). Debugging
OS-Specific NotesLinuxThere are a LOT of different flavors of Linux out there. I've provided the Ubuntu build more as an example of how the GitHub Action works, but I can't diagnose or trouble-shoot your Linux build (unless it's a consulting engagement). Feel free to post these in discussions! I will note, however, that much of the Linux trouble I have seen comes from some of the included integration
demonstrations. Try commenting out the loading of demo plugins in In theory, the Exception handler in the plugin loader code should catch the exceptions. In practice, on a few flavors of Linux something dies with a native exception that takes it all down. I get more support/issues for Linux builds than anything else, often for distros I've never heard of... which is cool but not something I'm really set up to deal with (short of paid consulting). That said, every Linux support issue so far has been resolved pretty easily by folks posting Maven or application log files in the discussion group. No promises, but go forth and post! HelpProblems? Make sure everything is installed and working right!
If you need consulting support, feel free to reach out at ChangeNode.com. Q&AIf you are using the template, browsing the Q&A is highly recommended. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论