#What can I use to compile Java to .dll?

1 messages · Page 1 of 1 (latest)

reef oxide
#

What can I use to compile Java to .dll in the current year since gcj is dead?

unique yewBOT
#

<@&987246399047479336> please have a look, thanks.

unique yewBOT
#

While you are waiting for getting help, here are some tips to improve your experience:

Code is much easier to read if posted with syntax highlighting and proper formatting.

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.

feral pelican
#

not sure why ur asking specifically for DLL

#

but apart from that, note that this is the intended route:

unique yewBOT
#

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:

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