I'm brand-new to using One-Jar, which is an excellent tool in theory. I'd rather distribute my Java application as a single jar file in order to make the user's work as simple as possible. After getting the build process to work correctly (it took a while), I had One-Jar working great - and then something changed and my libraries are no longer accessible. I'm hoping someone else recognizes the problem and can give me a boot in the right direction. I did inspect the source code of JarClassLoader.java, but a lot of it's over my head and the activity didn't really aid my understanding of what the issue might be.
Here's the structure breakdown:
(bunch of Boot/Handler/JarClassLoader class files)
MANIFEST.MF (blank file)
MANIFEST.MF (shown below)
MANIFEST.MF in the root META-INF folder reads:
Ant-Version: Apache Ant 1.6.5
Created-By: 1.5.0_14-b03 (Sun Microsystems Inc.)
Class-Path: library1.jar library2.jar
Obviously I'm missing something. I've tried changing the Class-Path attribute, including library1.jar and library2.jar in the /main directory, etc etc etc. The libraries are recognized and loaded just fine if I put them in the same folder as MainJar.jar, but to me that indicates the native class loader is being used and the One-Jar class loader is not being run. Any suggestions?
My apologies, the formatting of the folder structure got mangled when it posted. I've re-formatted it below.
.........(bunch of Boot/Handler/JarClassLoader class files)
.........MANIFEST.MF (blank file)
...MANIFEST.MF (shown below)
It looks like you're not using the Ant task to build your one-jar (in the latest 0.96 release). The correct structure under lib should be
It is not necessary to jar up your library jars.
I am using the Ant task (with some modifications to build.xml), but you are absolutely, 100% correct about the problem. My build.xml was jar-ing my two libraries into lib.jar. I changed it to simply copy the libraries into /lib and it works exactly as I want it to. Thank you for responding so quickly and for taking the time to solve my problem.
I'm having the some problem you were, and would like to try the solution Simon pointed out. How did you copy the libraries into /lib? Once you one-jar'ed the files was lib in the root of the one-jar'ed jar?
First, I just want to thank Simon for coming up with such a great tool. It has helped a lot in achieving my eventual goal of deploying an app across Linux and Windows.
I figured out the solution to the problem I ran into that I posted about above. I'll post it here in case somebody else runs into the same thing. Once I looked into the source code and realized one-jar inherits from jar, I figured out that anything you can do to jar, you can do to one-jar. So, to answer my original question, to include a file under the lib directory just do the following inside the one-jar tag section:
I hope that makes sense.
Your solution is basically what I use in the Ant task. The example Ant task does have a <lib> tag, and I just changed its environment variable to point to my own libs folder.
Log in to post a comment.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.