user3810361
user3810361

Reputation: 43

How to create single exe file of multiple JAR files?

I am trying to build JRE bundled exe file of my project that is a game some sort of with the help of this tutorial using launch4j , it has created exe file but whenever I run this file it gives 2 error messages:

  • A JNI error has occurred please check you installation.
  • Java exception has occurred (JVM Launcher).

P.S: My project contains extra JAR files that are (AbsoluteLayout, curvesapi-1.03, poi-3.15-beta1, poi-ooxml-schema-3.15-beta1, xmlbeans-2.6.0) in lib folder.

Upvotes: 3

Views: 2551

Answers (4)

I know I'm late but in case someone comes here looking for the answer...

Consider packaging a single jar file with all of your dependencies using maven-assembly-plugin for example, Here's a toturial.

How to Create an Executable JAR with Maven

Upvotes: 0

huellif
huellif

Reputation: 412

First of all export your project as single running .jar file which includes the .jar files themselves.

In Eclipse click right on your project -> "Export" -> "Runnable JAR file" -> "Package requred libraries into generated JAR". I don't know the exact way for other IDEs.

Can you execute this file? If yes convert the single .jar to a .exe via launch4j, otherwise check if your classpath is correct and if all libs are included.

In launch4j set your main class in the "classpath" tab, everything else is optional.

Upvotes: 0

Vivek Kalyanarangan
Vivek Kalyanarangan

Reputation: 9081

Just not worth the effort combining JARs to make a single exe.

If its mandatory that you need to do this, just build a wrapper class by importing all the JARs and ship that wrapper class out as a JAR then to exe

Upvotes: 0

Artur Opalinski
Artur Opalinski

Reputation: 1092

  1. Are you sure you want to convert your Java program to EXE? Is it worth the effort? What are you trying to achieve by doing so?
  2. Consider that you have to provide all environment to your program - as it uses many dependencies. The errors you get are indications of this.
  3. The movie you refer to can not be considered a complete guide. A better source for you to start will probably be this: Convert Java to EXE — Why, When, When Not and How

Upvotes: 2

Related Questions