I have a program I want to be able to be installed easily by any user, and I thought creating a native installer was the way to go. I used Netbeans 8.0's functionalities (Project properties > Enable native packaging, and Package as). I was able to create a working native installer. After installation, I have the following file tree:
+-- Project
\+-- app
\+--lib (containing all the jars used by the project)
\---Project.jar
\---package.cfg
\+--runtime
\+--jre (contains the current jre)
\---Project.exe
Executing the program from Project.jar works. However, when I try to launch Project.exe, I get the following error message on a window pop-up with no details whatsoever:
Failed due to exception from main class
To identify the source of the problem, I have used basic standard outputs and redirected them into a file thanks to the Windows command prompt. I got outputs until the first call to an external library. So it seems the library linking is not done. However, here's the content of my package.cfg
file:
app.mainjar=Project.jar
app.mainclass=project/Main
app.classpath=lib/firstlibrary.jar lib/secondlibrary.jar
The classpath is specified but does not seem to be recognized. I have tried inverting the slash (\) and changing whitespaces for ,
or ;
to no avail.
There is an easy way to reproduce the bug (Netbeans 8.0 and JDK 1.8u11):
- Create a new Java project in Netbeans
- Link any external library (.jar): right click on Libraries > Add jar/folder
- In the main method, instantiate an object referencing that library.
- Right click on the project's name > Properties > Deployment > Enable Native Packaging actions in project menu
- Right click on your project > Package as > EXE installer
- After build, go to the directory where the installer has been created, and launch the installer.
- At the end of the installation, go to the installation directory, and start the .exe. The error should occur.
Any idea how to fix this?