0

I've had to make some modifications to an old Java-based project which contains dependent JAR files in the project tree. When I last worked on this project 3 years ago, I was developing it in Eclipse and generating runnable JAR files using Eclipse's File -> Export... function, which worked great.

When I started working on this project again I switched to using IDEA. Following online documentation I was able to create a runnable jar using IDEA's Project Structure -> Artifacts pane.

However, I encountered several problems when trying to use the JAR file IDEA generates that I didn't encounter when using the one generated by Eclipse:

  • If I tried extracting the dependent JARs directly into my runnable JAR, I would get Java security exceptions about invalid signature files as the RSA/SF manifest files from my dependent JARs were getting extracted.

  • If I tried to embed the dependent JARs within my generated JAR file rather than extracting the class files from them, I encountered "class not found" exceptions.

To understand what was happening, I tried generating the JAR file using Eclipse as I'd done previously, which worked great. The difference seemed to be that IDEA was packing in a manifest file stored in my project tree like this:

Manifest-Version: 1.0
Class-Path: .
Main-Class: com.<company>.main.Main

In contrast, Eclipse was generating the manifest file during the export process, which looked like this:

Manifest-Version: 1.0
Class-Path: .
Main-Class: com.<company>.main.Main

Name: com/jgoodies/forms/layout/FormLayout$LayoutInfo.class
SHA1-Digest: J6yu1IuQZO0rgeF7Enl4p7u4ykU=

Name: com/jgoodies/forms/builder/ButtonBarBuilder.class
SHA1-Digest: 7ApcSFXKq2rw8IRkIl+R7y2rzIA=

Name: com/jgoodies/forms/layout/FormLayout$ComponentSizeCache.class
SHA1-Digest: cUMTPR0lwBEeQVUd3tsCFq6cMhA=

Name: com/jgoodies/forms/util/Utilities.class
SHA1-Digest: UbvvkJcHLyNbduyo07Hr2bSz06E=

...

It also excluded the RSA/SF files from the signed dependent JARs so that I didn't get any security exceptions when running the generated JAR.

My question is: is it possible to get IDEA to generate a manifest file similarly to how Eclipse does?

Tagc
  • 8,736
  • 7
  • 61
  • 114

0 Answers0