#What can I use to compile Java to .dll?
1 messages · Page 1 of 1 (latest)
<@&987246399047479336> please have a look, thanks.
While you are waiting for getting help, here are some tips to improve your experience:
If nobody is calling back, that usually means that your question was not well asked and hence nobody feels confident enough answering. Try to use your time to elaborate, provide details, context, more code, examples and maybe some screenshots. With enough info, someone knows the answer for sure.
Don't forget to close your thread using the command </help-thread close:1027500463647621170> when your question has been answered, thanks.
not sure why ur asking specifically for DLL
but apart from that, note that this is the intended route:
Due to the JVM and bytecode as intermediate execution stage, turning a Java application into a standalone executable (exe, msi, deb, rpm, dmg, pkg) is not trivial.
However, there exist various tools to do the job. They mostly differ in the details of the solution they create and hence also in their purpose:
- jpackage (the official tool) - creates an installer
- Launch4J - creates a wrapper executable that unwraps on execution
- GraalVM - attempts to create an actual native executable instead of wrappers or installers
This guide explains how to use jpackage, an official tool that is available in all JDKs since Java 16. The tool creates an installer for the application, so the end-user will get an executable that guides them through a setup where they can select installation path and tweak other settings, finally resulting in the application being installed on the machine (with a proper uninstaller, desktop shortcuts, start menu entries, ...): https://i.imgur.com/2V5ovUu.png
As an example, suppose you have a fat jar of your application called HelloWorld.jar, with a main class called Main. Put the jar into a dedicated release folder for simplicity. Execute the following command and you have an installer for your application in a folder called installer:
jpackage --input "release" --dest "installer" --main-class "Main" --main-jar "HelloWorld.jar" --name "HelloWorld" --win-dir-chooser --win-menu --win-shortcut --type exe
See the official documentation for more information on the available commands and for other operating systems:
- https://docs.oracle.com/en/java/javase/16/jpackage/packaging-overview.html#GUID-C1027043-587D-418D-8188-EF8F44A4C06A
- https://docs.oracle.com/en/java/javase/16/docs/specs/man/jpackage.html
Here is an example for a more complex setup which also associates file endings to the application, has a custom icon and more: https://pastebin.com/cfzqSKnW