ok, I'm sorry for posting this in the intermediate, and not the beginner forum, but I dont know how this one fits.
so, my problem is.
I have a class that uses jasperreports API to create reports in PDF format.
ok, no problem until now, but... my class needs some jasperreports JARs to work, so my answer to this was creating a JAR file, in the JAR, I put the class and the other JARs I nedd together, and I also define a manifest file like this:
Class-Path: commons-beanutils-1.7.jar commons-collections-2.1.jar commons-digester-1.7.jar commons-logging-1.0.2.jar commons-logging-api-1.0.2.jar itext-1.3.1.jar jasperreports-3.0.0.jar postgresql-8.2-504.jdbc3.jar
well it should work no?
but it doesn't.
my created JAR file, need to be placed in the same directory as the JARs that is inside itself, otherwise it don't work, saying that some classes are missing.
I really dont understand abour JAR structure and advanced things that could help me now, but you guys jsut keep helping me, so I just keep needing you.
after this is solved, i promess you guys I pay you a round of beer.
This is the manifest declaration that you have mentioned. But while making your jar file are you adding all the jar files specified in the manifest along with you class files? As per my knowledge this is required.
so my answer to this was creating a JAR file, in the JAR, I put the class and the other JARs I nedd together,
If by this you mean you've actually added the other jars into your jar file and not just added the jar names to the manifest file then this is your problem. You can't add the other jars to your jar as the classloader can't load jars from a jar file. Adding the jar file names to the manifest file just tells the classloader to look in the named jars files for classes but it expects to find the jars on the classpath eg in the same directory.
If you want to package everything into a single jar file then you could try something like this product (I've not used it myself so can't vouch for it).
Lucas Franceschi wrote:i couldn't figure out how to use one-jar application that you have sent me.
As I said I've never used it myself but it did look like it had documentation with it.
so, as you said, and I understood, i'm wrong, because java classloader don't know how to load classes from a jar inside a jar, right?
so that if i put that JARs on the classpath in the manifest file it will not change anything, since that the jars inside are "unreachable" for java, right?
Yes. The reason for adding the jar names to the manifest is so that your application can access those jars without you having to explicitly add them to the classpath every time you start the application. Which is also why
so, as well, to make this application work in one single jar, what should I do? using the one-jar application dont seem to friendly for me, but if its necessary i will.
You could try searching for other jar packagers, I know there are also several that package everything up and create a windows style exe (but then you are stuck with using it on a windows platform).