0

I try to build an runnable jar file. I know how to include the necessary jar libraries into my generated jar. But i am using an SDK and am referencing to one jar of it, which has to stay at this necessary place. So if I copy the jar into some other folder (like lib folder in my project) it doesn´t work. Does anyone know how i can reference this jar file?

Tupfer
  • 57
  • 1
  • 7
  • add it to your classpath? – Scary Wombat Nov 28 '17 at 07:53
  • ..or use maven? – Jack Flamp Nov 28 '17 at 07:53
  • No, its already in my classpath, I can run the application within eclipse, but not as a exported runnableJar file – Tupfer Nov 28 '17 at 07:54
  • see this answer https://stackoverflow.com/a/12357552/2310289 – Scary Wombat Nov 28 '17 at 07:56
  • @ScaryWombat thanks for your answer, but i dont have a jar into a jar. My problem is the i need to reference a external jar file, which has to stay at a specially place because its referencing other files. So in eclipse, i cant just add it to my classpath and the jar stays at its place. but if i export my application into a runnable jar, eclipse packages or exports a referenced jar files into the new runnarble jar. – Tupfer Nov 28 '17 at 08:15
  • read the answer again. *By using the Class-Path header in the manifest,* – Scary Wombat Nov 28 '17 at 08:19
  • However you do it, you must allow the JVM that runs the jar to find the required library. There are two simple ways. 1) When launching the jar, provide the `-cp` option with the required jar. 2) Add a manifest that includes a `Class-Path` header. Option 2 is less portable as it hardcodes the external jar file location, while option 1 means you can change it at runtime if needed. – Jim Garrison Nov 28 '17 at 08:26
  • Sorry, still don´t know how to do that... – Tupfer Nov 28 '17 at 12:21
  • The solution was to copy the .jar and some other files the .jar referenced into the same folder because there were realtive paths linked in the .jar – Tupfer Jan 22 '18 at 08:24

0 Answers0