3

Developing on the Mac with IntelliJ 9.0.2 Community Edition.

I have a program which depends on two library jars. I have figured out how to get IntelliJ to make me a jar of my source (with the Artifact tab), and even to include the two jars in it.

However, if I get a listing of the jar file it produces, it looks like this:

com/acme/MyClass1.class
com/acme/MyClass2.class
...
mylib1.jar
myLib2.jar

And, no surprises, if I double-click the jar file, it gets a NoClassDefFoundError the first time it tries to access a class in one or other library jar.

It seems I need to tell IntelliJ to "inline" the library jars -- but this menu option is always greyed out!

Does anyone have any idea how to get jars inlined in a jar artifact?

skiaddict1
  • 149
  • 2
  • 8

3 Answers3

2

IDEA doesn't support it yet, you can use Ant integration to package your jar (either by unpacking all the jars into the temp folder and then packaging the project output plus this temp folder into the single jar or by using some Ant task like jarjar).

If you want this feature to appear in the future IDEA versions, please vote for the request.

CrazyCoder
  • 389,263
  • 172
  • 990
  • 904
  • Sure, I actually can dig out the appropriate ant code from some old project, so it won't be a biggie. But to have IntelliJ "pretend" that it's possible (via a menu item, which admittedly is always greyed-out, and a bland statement in the online manual -- "Use this option to have the selected artifact disassembled and its its components presented as independent elements.") and then not be possible is somewhat...anti-climactic, shall we say!! :-) – skiaddict1 May 24 '10 at 02:46
0

Having the dependency JARs included in your JAR should allow yoru code to run successfully. You probably don't have the JARs on your classpath.

Jesse Webb
  • 43,135
  • 27
  • 106
  • 143
0

I will use Maven Assembly plugin. Its simple and will give you a neat little jar file..

uncaught_exceptions
  • 21,712
  • 4
  • 41
  • 48