0

I'm developing a little framework which depends on a library (jar file). I managed to include that dependency in the final framework jar file. But when I include this framework jar (which includes the other library) I can use the framework's classes but I cannot use the classes of the dependency library included in the framework jar.

How can I manage to solve this? And is it a good practice to include a third party library in my framework (even it's under GPL license)? I just want to reduce the work the framework user (developer) has to do.

3
  • 1
    "And is it a good practice to include a third party library in my.." If anything follows that besides "..apps. run-time class-path" the answer is almost certainly 'no'. It is possible to jump through hoops to load Jars inside other Jars, but it makes a lot more sense to deploy the app. in a way that was intended for Java applications. What type of app. is it? (E.G. Web-app., desktop app., console app. ..). Commented Oct 22, 2012 at 20:36
  • 1
    By doing that, you just make the developer's life much harder, since jar files are NOT supposed to be nested into each other. Google for java jar tutorial. Commented Oct 22, 2012 at 20:40
  • Sometimes the customer wants only 1 jar but you have 3-d party jars(like gson,log4j ...) anf your private 5-10 jars. With ant you open all jars and fetch new one with all packages (a lot packages). But since you provided javaDoc to customer it's not mater how your new jar is complicated. Commented Oct 22, 2012 at 20:43

1 Answer 1

1

How can I manage to solve this?

Nesting JARs is possible if you use a special classloader such as provided by OneJar, but it leads to rather long startup times and of course adds another dependency and complication.

Managing a classpath with mulitiple dependencies in JAR files is something all Java developers are familiar with. I see no value in trying to avoid it.

And is it a good practice to include a third party library in my framework (even it's under GPL license)?

That depends - if your framework is not also GPL, you're in violation of the license and could be sued. And it doesn't matter whether you actually include the GPL jar or not.

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

1 Comment

OK, I knew it could be that this is a bad practice. So I include this dependency in the framework's documentation.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.