I wrote an application with java and convert it to execute jar file, my project is depend on “jxl.jar”.
Is there any way to copy “jxl.jar” to my jar file and after that call it.
I think that called “Nested Jars” ?!?
Thanks a lot
Best Regards,
Mike
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The simplest way is to unpack
jxl.jarand pack it into single jar together with your class files.You can also put
jxl.jarinto your jar, load it usingJarClassLoaderand call using reflection, but it’s probably not worth the effort and added complication.This should look something like this:
Unfortunately it doesn’t really work with nested jars.
URLClassLoaderhas problems with them. You can extract your nested jars to temporary files and pass them to URLClassLoader. You can also use customURLStreamHandleras described here, it may even be a working solution.