This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm looking at a project in Eclipse and, for the life of me, I can't figure out what I'm doing wrong.
The application I'm using utilizes an external API in order to connect to an FTP server, among other things. In Eclipse, I've pulled all of my needed JAR files into the build path and the application works perfectly. However, when I try to export the application as an executable JAR file, it's all falling apart.
I'm using Eclipse 2.1 (it's an old version, but I haven't used it in quite some time so I haven't upgraded it and lack the time to do so right now, anyway). From there, I select "Export..." and select JAR file.
The JAR File that it generates contains all of my CLASS files as well as a couple other files, named .classpath, .project, and Manifest.mf, respectively. Following are the contents of .classpath and Maifest.mf, as they may be relevant:
From the .classpath file, I would expect the application to find the file ftp.jar, which, indeed, is sitting on my C: drive. Unfortunately, it fails to do so. Whenever I execute the application, I eventually get this error:
I've tried everything I can think of, but it refuses to find that file. What can I do to make this work?
Is there a way to deploy my JAR file with all of the JAR files it's dependent upon included within that JAR file? It would seem that, in such a way, deployment to other machines would be easier. [ July 12, 2005: Message edited by: Corey McGlone ]
I'm assuming you are running this with the -jar option.
Yup, running it using java -jar NameOfJarFile.jar.
I've even tried using java -jar -classpath C:\ftp.jar NameOfJarFile.jar, but that didn't help, either.
You need to create your own Manfest.mf and include the Class-Path element as discribed Here
I'm not sure how in Eclipse you specify the manafest to include in the jar but, it should be that difficult.
Eclipse normally created the Manifest file for me, but I tried making my own, which included a Class-Path header. I used something like this:
However, I'm guessing that assumes that the JAR file ftp.jar would be located within the .jar file of the application. While I know how to define the Manifest file, I don't know how to include those external .jar files within the application .jar.
If I remember correctly (I'm not currently at that workstation), I also tried something like this:
I think that one might have given me errors.
Joined: Jun 13, 2000
adding Class-Path: ftp.jar assumes the jar is in the same directory where you started the app.