1

I exported my project using the Export as Runnable Jar option in Eclipse, which worked perfectly fine originally.

However, I now have a splash image that I need to include in the manifest for the Runnable jar, which cannot be specified when exporting as a Runnable Jar.

So, I tried to do Export as a Jar and just set the manifest manually through there. It allows me to set the manifest, but another problem arises. It won't let me extract/package the required libraries like the Runnable Jar export allowed me to do.

If someone could tell me a method where I could export the project as a runnable jar with a custom manifest and the extraction of required libraries into the jar, I would highly appreciate it.

Gigi Bayte
  • 33
  • 1
  • 5
  • 1
    How about to create a simple Ant build script (via _File > New > File_: `build.xml`): https://ant.apache.org/manual/tutorial-HelloWorldWithAnt.html – howlger Aug 27 '17 at 18:28
  • That sounds interesting, but I'm quite confused. Let's say I was creating a runnable jar in which I have the required dependencies of a.jar, b.jar, and c.jar. I have the main runner class Main.java. How would I do that? – Gigi Bayte Sep 04 '17 at 03:55
  • See e. g. https://stackoverflow.com/q/1821803/6505250 – howlger Sep 04 '17 at 06:50

2 Answers2

6

Thanks to howlger for helping me find the solution!

I first acted as if I wanted to create a runnable jar by right clicking my project, clicking export, and clicking runnable jar.

export

runnableJar

Then, I exported it as a runnable jar but also checked to get the ant build script to my desktop.

antBuild

In the generated build.xml file, I edited it using a text editor program and added the SplashScreen-Image attribute

build

Now, to use this new build script to export the project, right-click the project file, go to properties, go to builders, click New..., and go to Ant Builder

properties

builders

antBuilder

Choose the location of the modified build file you exported for the Buildfile, and choose the project folder as the base directory for the Base Directory.

finalBuild

And that's how you can modify the manifest of a runnable jar file.

Update:

To run the necessary ant configuration, click the arrow next to the button to the right of the green play button that looks like this:

playButton

Once you click the arrow, click "External Tools Configurations..."

external

Add the Ant Build configuration previously made, or if it doesn't show up, add it using the previous steps.

Once this is done, click close and click on the aforementioned play button with the red toolbox next to it to build it.

Gigi Bayte 2
  • 838
  • 1
  • 8
  • 20
  • But how to do you actually export the runnable jar with this configuration? – Anonymous Sep 12 '21 at 01:09
  • @Anon As mentioned above, "click on the aforementioned play button with the red toolbox next to it to build it." The built artifact is the runnable .jar file. – Gigi Bayte 2 Sep 13 '21 at 03:09
1

Another approach is to:

  1. Export your runnable jar in Eclipse
  2. Create a file (addToManifest.txt) with your manifest permissions inside. For example:

Permissions: all-permissions

  1. update the manifest using the jar command:

jar ufm dist\myApp.jar addToManifest.txt

  1. Then sign your jar with the standard jarsigner

jarsigner -keystore yourkeystore.jks myApp.jar yourAlias

aubreybourke
  • 439
  • 1
  • 5
  • 17