0

Hi I know there are tons of articles about how to merge jars, but my problem is a little different.

I want to use a bash script to merge jar files. All my jar (from Processing) are lying in ./lib Here is what I do:

mkdir tmp FILES=lib/*.jar for T in $FILES; do (cd tmp; jar -xf ../$T) done jar -cfm combined.jar tmp/META-INF/MANIFEST.MF -C tmp . 

Of course I get a jar File but it's not really acting like it should.

BTW: I make sure that the jar extracted last is the main applications jar.

5
  • How is it acting ? How should it be acting ? Commented Jan 31, 2013 at 13:46
  • It's unclear what you're asking for. Or what making sure "the jar extracted last is the main applications jar" means. Commented Jan 31, 2013 at 13:48
  • Because each JAR includes it's own Manifest. As all other JAR are just libraries and not executable I need to make sure to use the right Manifest with the right Main Class. It acts in a way that I doesn't find some of the libraries referenced. Commented Jan 31, 2013 at 13:52
  • @John Not finding classes referenced in other jars means something else is going wrong; at worst the broken manifest would try to run the wrong main. Also, if you don't use an @ reply the person you're responding to may not be notified you've replied. Commented Jan 31, 2013 at 13:56
  • I'd use Apache Ant to achieve that. Using native scripts somehow hurts the Java way of coding (even when packaging): "write once, bug, I mean, run everywhere" ;-) Commented Jan 31, 2013 at 13:58

1 Answer 1

1

This script works fine for me when I grab ALL the required jars from Processing (2.1 on OSX in my case). Here are the contents of my 'lib' folder before running it:

MySketch.jar core.jar gluegen-rt-natives-macosx-universal.jar gluegen-rt.jar jogl-all-natives-macosx-universal.jar jogl-all.jar 

If you use any libraries, you need to include ALL the jars for those as well.

Sign up to request clarification or add additional context in comments.

1 Comment

rednoyz good that it works for you. I haven't jumped to Processing 2.1 yet as the OpenGL doesn't work. But I'll try. I have figured out another way tho.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.