This content has been marked as final. Show 5 replies
Your application has "external dependencies", other jars that need to be on the classpath. You can easily see this by opening up your application jar and then opening META-INF/MANIFEST.MF in a text editor. It will contain a line 'class-path' which lists all the jars your application needs, and where it will look for them. A general design pattern is that they go in a 'lib' subdirectory.1 person found this helpful
So yeah - you forgot to copy the other jar(s) needed.
Thanks for your explanation.
These are the contents of the manifest:
So if I understand correctly, I should download these jars: pdfbox-1.7.1.jar, fontbox-1.7.1.jar, commons-log
Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.3 Created-By: 1.7.0_13-b20 (Oracle Corporation) Class-Path: lib/pdfbox-1.7.1.jar lib/fontbox-1.7.1.jar lib/commons-log ging-1.1.1.jar lib/jna-3.5.1.jar lib/platform-3.5.1.jar X-COMMENT: Main-Class will be added automatically by build Main-Class: renamepdf.RenamePDF
ging-1.1.1.jar, jna-3.5.1.jar, platform-3.5.1.jar
And where should I put them?
Also, isn't a jar file supposed to work on its own without further intervention? What if I need to give the jar file to different people, I have to install all these jars on their pc's?
Thanks very much!
you should already have them - in the machine where the jar was built.
And where should I put them?As you can see, the class-path refers to a 'lib' subdirectory as I suspected. So you would distribute the application as:
You have to be careful how you run it. Java will look for the libraries relative to the working directory, which is the directory where the actual java or javaw command is executed. This is no issue when you run the jar by just double clicking on it / on a shortcut to it.
This is also nothing unusual, any native application comes with a big pile of additional files next to the executable, including a pile of DLL files which you can lazily compare to a jar.
isn't a jar file supposed to work on its own without further intervention?That refers to being able to double click on the (executable) jar file in an OS gui and the application then running. You still need to package and deploy it properly. Which means you need to know how to package and deploy it properly.
I have to install all these jars on their pc's?You could...
- just copy them with the jar; zipping it all up works wonders
- create an installer, which is the professional solution applied to nearly all software in existence
- use webstart
- use a onejar solution to cram everything into one huge jar; you have to be careful with this because you may be breaking licenses depending on what jars you use.
Thanks for your very detailed explanation! :-)
Will try it out.
As regards the installer, I'm not experienced on that, but will check out some tutorials on the net.
Cheers & good day.
Following your explanation, it worked now.
Thanks very much for your help.