Home > OS >  How can I package my Java Maven desktop app with Netbeans 12.6 so that it can be installed on multip
How can I package my Java Maven desktop app with Netbeans 12.6 so that it can be installed on multip

Time:03-09

I've been searching high and low for answers for this, but it has proved pretty hard. Maybe I'm just not searching for the right thing, but I'm not sure.

Essentially, I have an app. I want it to work on my Windows system and another MacOS system. I'd also like it to be installed as you would an application made for the average computer user. I know I can run it from the console with java -jar, but I'm more hoping to get some kind of installer, like the .exe/.msi files you get from C# and VS Studio.

I've found a lot of solutions, but very few are up to date (either broken links or depreciated) and even less mention using the Netbeans Maven projects. For example, mosto of the advice I've seen so far says:

  1. Clean and build
  2. Run the .jar file from the dist folder in the PROJECT_HOME parent folder

The issue is the doing the clean and build action with a Netbeans Maven project doesn't create a dist folder. And anyway, this doesn't help me make a clean, neat desktop application which is installed in the way most people are used to.

Does anyone know how to do this, or can anyone point me in the direction of some relevant documentation I can check? Thanks in advance.

CodePudding user response:

For building your application into a jar file, run mvn clean package which should create a target folder which contains the jar. Also, consider looking into the configuration for maven-jar-plugin maven-shade-plugin and maven-assembly-plugin to customize the jar more.

For creating an installer for your application such as an .exe or .msi file, I'd recommend using Inno Setup (link) or maybe look into jpackage depending on your Java version and environment.

  • Related