0

I have a wrapper that I've built ontop of the Netty library.

I'm trying to export the wrapper as a .JAR so when I add it to another project I can use it's features.

The .JAR file has the Netty.jar file in the dependencies folder, however when I try to import something in my project that has my .jar file as a library, I can't import any netty functions.

Of-course, the .JAR file can access the Netty.Jar fine.

Is there any way to make it so I don't have to have my .jar and the netty.jar as libraries, and instead just have my .jar file share the netty.jar to the project?


Example:

-|_My Project
---|_MyLibrary.Jar
-----| Netty.Jar

Which would mean you would only have to import 'MyLibrary.Jar' to use the features that come with 'Netty.Jar'

Or do I have to do it like this


-|_My Project
---| MyLibrary.Jar
---| Netty.Jar
Hobbyist
  • 15,888
  • 9
  • 46
  • 98

1 Answers1

0

Standard Java is not able to load Jar-Files within Jar-Files. So you have to do it the second way you propose, to have the two libraries next to each other. What you can do is to have a Manifest in MyLibrary.jar that contains a classpath which points to the Netty.jar. This way, you will only have to add MyLibrary.jar to the classpath, but not both. But still, both jar files need to be on the filesystem, just not on the classpath.

cello
  • 5,356
  • 3
  • 23
  • 28
  • So the user ( if someone else wanted to use this ) would still have to download the Netty.jar, even though it's already inside of 'MyLibrary.Jar' ? – Hobbyist Oct 31 '14 at 09:01
  • Yes, at least with standard Java. There are alternative class loaders, e.g. OneJar, that might help, but I wouldn't use them for a library, only for standalone applications. Also have a look at this question: http://stackoverflow.com/questions/12357136/reference-jars-inside-a-jar – cello Oct 31 '14 at 09:04
  • What a drag, I guess the other alternative is to use the source of the Netty library in my project, instead of just referencing the .Jar as a library, and then building all of it into a .Jar, would this give me the result I'm looking for? – Hobbyist Oct 31 '14 at 09:07