0

I have developed an application in eclipse that requires java3d. I have the jars for java3d, but I'm not sure how to put them into my final jar such that my application can reference the required classes. I'm on a mac and just making the jars with the command line, this is my script:

cd /Users/landonsilla/Sites/3dviewer/bin
jar -cvf CyarkCloudViewerPro.jar pointCloudTest/*.class pointCloudTest/icons/*.png 

It's pretty simple, it just takes some class files and some images and puts them in the jar. How do I put the java3d jars in there?

The end goal is to deliver this on my website via jnlp. My application works, and the jnlp deliver mechanism I implemented works fine. However, my app crashes when trying to do java3d stuff.

This seems like a simple and common request, I just can't figure out the answer.

Veger
  • 37,240
  • 11
  • 105
  • 116
Landon
  • 4,088
  • 3
  • 28
  • 42
  • See http://stackoverflow.com/questions/81260/java-easiest-way-to-merge-a-release-into-one-jar-file or http://stackoverflow.com/questions/183292/classpath-including-jar-within-a-jar – John Flatness Aug 12 '11 at 22:38

1 Answers1

1

You just add the jar files into the main jar, and then announce the libraries on your MANIFEST.MF file. Example of the MANIFEST.MF:

Manifest-Version: 1.0
Main-Class: fi.ropecon.contv.client.ConTVClient
Created-By: "Jari Juslin <zds@iki.fi>"
Class-Path: lib/j2ee.jar lib/jbossall-client.jar lib/log4j.jar lib/jnp-client.jar

"Main-Class" is the class that's called to start the program when you start program with java -jar command. Class-path is, well, normal Java classpath, but relative to the root of the main jar archive.

Zds
  • 4,311
  • 2
  • 24
  • 28
  • Ok, can you please explain exactly how to "add the jar files into the main jar"? I know a jar is just a zip file, so do I unzip, make a folder called lib, drop the jar in there, then rezip it? – Landon Aug 12 '11 at 23:00
  • Yes, that works. Usually people use build tools like "ant" to do that. They allow you to list what directories and files are included and where. – Zds Aug 12 '11 at 23:15
  • I think you can also just list the included jars on the command line of your "jar" command, after the classes. The jar tool really acts like "tar" in *nix, it's just a fancy compression tool. – Zds Aug 12 '11 at 23:17
  • Ok, I put the jars in a lib directory and then changed my command to, jar -cvf CyarkCloudViewerPro.jar pointCloudTest/*.class pointCloudTest/icons/*.png lib/*.jar. Then I unzipped the jar, and added this into the manifest file Class-Path: lib/j3core.jar lib/j3dutils.jar lib/vecmath.jar. Then I signed the app and uploaded it. It didn't work – Landon Aug 12 '11 at 23:40
  • If it's helpful, you can open up the jar itself at: http://archive.cyark.org/point_cloud/package.jar – Landon Aug 12 '11 at 23:43