0

I do have a standalone java program consisting of my own jar and many dependent libraries as single archives (build wby maven, actually 15 JAR files in total). Do some one have already a nice solution she/he can recommend to me how to avoid this and to make packaging smarter?

For example packaging like EAR archives do would be great, but is there any standalone EAR class loader I could use from my NON-Java EE application?

4

2 に答える 2

2

There's the Eclipse Fat Jar plugin. In their own words:

The Fat Jar Eclipse Plug-In is a Deployment-Tool which deploys an Eclipse java-project into one executable jar.

It adds the Entry "Build Fat-JAR" to the Export-Wizard. In addition to the eclipse standard jar-exporter referenced classes and jars are included to the "Fat-Jar", so the resulting jar contains all needed classes and can be executed directly with "java -jar", no classpath has to be set, no additional jars have to be deployed.

Jars, External-Jars, User-Libraries, System-Libraries, Classes-Folders and Project-Exports are considered by the plugin. The Main-Class can be selected and Manifest-files are merged. The One-JAR option integrates a specialised Class-Loader written by Simon Tuffs ( http://one-jar.sourceforge.net/ ) which handles jar-files inside a jar. Individual files and folders can be excluded or added to the jar. Different settings can be stored and re-executed as "Quick Build" via the context-menu.

于 2012-07-09T13:48:54.880 に答える
1

Well, I don't know which IDE you're using. I have Eclipse Indigo (3.7). For me the steps are simple:

  1. Right-click on your Java Project folder
  2. Click Export
  3. On the window that comes up select Java>Runnable JAR file and then click Next
  4. On the next window, select the configuration you want your program to run in
  5. Select your destination folder
  6. On the "Library handling:" part make sure you select "Extract required libraries into generated JAR", this will unpack your libraries and then repack them into your finished .jar
  7. Click Finish
  8. You're done! Enjoy.

If you have an eclipse version less than Ganymede (3.4) you need to get the Fat Jar Plug-in.

于 2012-07-09T14:05:28.990 に答える