Search code examples
javacross-platformfile-associationjdic

What files does JDIC need to run?


I'm trying to call JDIC from my application, but I can't get it to run. What files do I need and where? From what I've been able to gather from their site, I basically need to put jdic.jar in classpath... however there is also a lib folder with jdic.jar with a bit different size, and jdic_native_applet.jar, jdic_stub_unix.jar, jdic_stub_windows.jar and several folders with what I gather are platform specific files.

I get this exception when instantiating AssociationService:

java.lang.ClassNotFoundException: org.jdesktop.jdic.filetypes.internal.AppAssociationReaderFactory_windows
    at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
    at org.jdesktop.jdic.filetypes.AssociationService.<init>(Unknown Source)
    at QuickTest.main(QuickTest.java:101)

I've tried last "official" release and last alpha release. I'm running Java 6 and Win7 64bit. Does JDIC even work under Win7 (or 64bit, although I use 32bit Java)? I see no release after 2006, and no activity in the project after about 2008... while Win7 came in 2009.

I know that parts of JDIC, like Desktop, were included in Java 6, however that doesn't seem to be the case with file associations.

And if it doesn't, are there any (hopefully cross-platform) alternatives for managing file associations? There are some things for Windows only that I tried, but that requires running native commands with administrator privileges which I don't know how to pull, apart from asking user to run my app as administrator and then use Runtime.exec()...

If there are no alternatives to JDIC, I'm interested if anyone has managed to handle file associations well with cross-platform installers?

UPDATE: OK, figured part of it... everything from windows folder needs to be in root folder. However now I get this exception which brings me back to my original question:

Exception in thread "main" java.lang.UnsatisfiedLinkError: D:\Sources\TheWorkspace\Test\jdic.dll: Can't load IA 32-bit .dll on a AMD 64-bit platform
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1778)
    at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1703)
    at java.lang.Runtime.loadLibrary0(Runtime.java:823)
    at java.lang.System.loadLibrary(System.java:1030)
    at org.jdesktop.jdic.init.JdicManager$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at org.jdesktop.jdic.init.JdicManager.loadLibrary(Unknown Source)
    at org.jdesktop.jdic.filetypes.internal.WinRegistryWrapper.<clinit>(WinRegistryWrapper.java:36)
    at org.jdesktop.jdic.filetypes.internal.WinRegistryUtil.isSubKeyExist(WinRegistryUtil.java:192)
    at org.jdesktop.jdic.filetypes.internal.WinRegistryUtil.isFileExtExist(WinRegistryUtil.java:910)
    at org.jdesktop.jdic.filetypes.internal.WinRegistryUtil.isFileExtExist(WinRegistryUtil.java:939)
    at org.jdesktop.jdic.filetypes.internal.WinAppAssociationReader.isFileExtExist(WinAppAssociationReader.java:163)
    at org.jdesktop.jdic.filetypes.AssociationService.getFileExtensionAssociation(Unknown Source)
    at QuickTest.main(QuickTest.java:103)

Solution

  • Can you recheck the java you are using to run this? The error typically occurs when trying to load a 32-bit dll from a 64-bit java. jdic does work for us on 64-bit Windows 7 with 32-bit java.