0

I am new to Java and to eclipse. My project uses 3rd party jars that are dependent on native dlls. I placed these dlls under bin folder and this works fine within eclipse.

I used "Fat Jar Exporter" eclipse plugin to export my project as an executable jar. Using JDK jar utility I noticed that the jar is looking for javafx dlls in a target outside the fat jar eventhough this dll is present in the root of the jar.

How can I modify the jar manifest so that it picks these dlls from within the jar or should I set some path when I am exporting the jar out of eclipse.

I tried to add glass.dll; processor=x86;osname=win32, in Bundle-NativeCode but it did not work.

Here is how the manifest file looks,

Manifest-Version: 1.0
Created-By: Fat Jar Eclipse Plug-In
Main-Class: com.bosch.mvci.ui.UI

Name: com/sun/jna/
Implementation-Title: com.sun.jna
Implementation-Vendor: JNA Development Team
Implementation-Version: 3.4.1 (b671)
Specification-Title: Java Native Access (JNA)
Specification-Vendor: JNA Development Team
Specification-Version: 3
Bundle-ManifestVersion: 2
Bundle-Name: jna
Bundle-Description: JNA Library
Bundle-SymbolicName: com.sun.jna
Bundle-Version: 3
Bundle-RequiredExecutionEnvironment: J2SE-1.4
Bundle-Vendor: JNA Development Team
Bundle-ActivationPolicy: lazy
Export-Package: com.sun.jna,com.sun.jna.ptr,com.sun.jna.win32,javafx
Bundle-NativeCode: com/sun/jna/win32-x86/jnidispatch.dll; processor=x8
 6;osname=win32, com/sun/jna/win32-amd64/jnidispatch.dll; processor=x8
 6-64;osname=win32, com/sun/jna/w32ce-arm/jnidispatch.dll; processor=a
 rm;osname=wince,  com/sun/jna/sunos-x86/libjnidispatch.so; processor=
 x86;osname=sunos, com/sun/jna/sunos-amd64/libjnidispatch.so; processo
 r=x86-64;osname=sunos, com/sun/jna/sunos-sparc/libjnidispatch.so; pro
 cessor=sparc;osname=sunos, com/sun/jna/sunos-sparcv9/libjnidispatch.s
 o; processor=sparcv9;osname=sunos,  com/sun/jna/aix-ppc/libjnidispatc
 h.a; processor=ppc;osname=aix, com/sun/jna/aix-ppc64/libjnidispatch.a
 ; processor=ppc64;osname=aix,  com/sun/jna/linux-ppc/libjnidispatch.s
 o; processor=ppc;osname=linux, com/sun/jna/linux-ppc64/libjnidispatch
 .so; processor=ppc64;osname=linux, com/sun/jna/linux-i386/libjnidispa
 tch.so; processor=x86;osname=linux, com/sun/jna/linux-amd64/libjnidis
 patch.so; processor=x86-64;osname=linux, com/sun/jna/linux-arm/libjni
 dispatch.so; processor=arm;osname=linux, com/sun/jna/linux-ia64/libjn
 idispatch.so; processor=ia64;osname=linux,  com/sun/jna/openbsd-i386/
 libjnidispatch.so; processor=x86;osname=openbsd, com/sun/jna/freebsd-
 i386/libjnidispatch.so; processor=x86;osname=freebsd, com/sun/jna/fre
 ebsd-amd64/libjnidispatch.so; processor=x86-64;osname=freebsd,  com/s
 un/jna/darwin/libjnidispatch.jnilib; osname=macos,glass.dll; processo
 r=x86;osname=win32,javafx-font.dll; processor=x86;osname=win32,
user1724114
  • 269
  • 5
  • 14
  • Given that `javafx` implies a GUI, the best deployment strategy might be to deploy it using [Java Web Start](http://stackoverflow.com/tags/java-web-start/info). For JWS, the natives are put in the root of a signed Jar and added to the class-path. JWS does all the rest automatically. – Andrew Thompson Jan 11 '13 at 03:12
  • I have modified the post as per your first comment. Please guide. – user1724114 Jan 11 '13 at 21:14
  • 1
    I do not believe that Java can load DLLs from a jar without doing some horrible trickery like copying them onto the hard disk just before loading them. See this question: http://stackoverflow.com/questions/1611357/how-to-make-a-jar-file-that-include-dll-files What is so bad about releasing your project as a directory structure? – Andy Till Jan 11 '13 at 22:42

1 Answers1

0

This is actually correct:

Windows, by default, looks for a .dll in the current users directory (in Java Terms, this is user.dir System Property)

There's no way your Java App can load a DLL from inside the Jar. You need to copy it somewhere windows is able to Look (simply copying to user.dir should do the trick)

aldrinleal
  • 3,559
  • 26
  • 33