no suitable image found - java JNI

Discussion in 'Mac Programming' started by DJRichCMusic, Sep 1, 2010.

  1. macrumors newbie

    Aug 31, 2010
    Hi all,

    I posted this on another thread for someone with similar issues, but to no avail, I will try here and hopefully someone can help me out.

    I have a JNI library which I built, which works correctly with another application that I built.

    I am working on a 'version 2' but the library is giving the following.

    any help would be appreciated.

    My Stack Trace:

    Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/rcook/NetBeansProjects/MPX Print Suite/libEyeOneNative.dylib: no suitable image found. Did find: /Users/rcook/NetBeansProjects/MPX Print Suite/libEyeOneNative.dylib: mach-o, but wrong architecture
    at java.lang.ClassLoader$NativeLibrary.load(Native Method)
    at java.lang.ClassLoader.loadLibrary0(
    at java.lang.ClassLoader.loadLibrary(
    at java.lang.Runtime.loadLibrary0(
    at java.lang.System.loadLibrary(
    at com.mpx.device.eyeone.EyeOneDevice.<init>(
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(
    at java.lang.reflect.Constructor.newInstance(
    at java.lang.Class.newInstance0(
    at java.lang.Class.newInstance(
    at com.mpx.plugin.device.PluginDeviceLoader.loadDevices(
    at com.mpx.plugin.device.PluginDeviceLoader.getInstance(
    at com.mpx.printsuite.TestDevicePlugin.main(


    Non-fat file: libEyeOneNative.dylib is architecture: i386

    Java Version:

    java version "1.6.0_20"
    Java(TM) SE Runtime Environment (build 1.6.0_20-b02-279-10M3065)
    Java HotSpot(TM) 64-Bit Server VM (build 16.3-b01-279, mixed mode)

    Many thanks in advance.


  2. macrumors G4


    Jun 6, 2003
    Solon, OH
    The error message posted suggests right away what the problem is. You have an Intel Mac, no? You're trying to run 64-bit Java (the default on Snow Leopard) with a 32-bit .dylib. That won't work. You need to either compile a 64-bit version of your .dylib file, or run Java in 32-bit mode.
  3. thread starter macrumors newbie

    Aug 31, 2010
    Thanks for your prompt reply.

    I thought this myself but the dylib works fine with my other aplication.

    I am running it through the ide rather standalone, this might have something to do with it.

    I'l have a play.

    Thanks again
  4. macrumors 6502a

    Jan 15, 2007
    The IDE(if you are launching it from an app bundle) may very well specify use 32 bit(or just have a 32 bit Java application stub, no 64 bit stub).

    If you launch with a 32 bit stub the OS automatically loads the 32 bit java no matter what the order of the jvms is in your preferences. However if you launch it via the java command(or just double clicking on the jar), it will take your preferences into account and like was said before defaults into 64 bit.
  5. macrumors 604

    Aug 9, 2009
    Any application that requires a specific JVM 64-bit or 32-bit mode must specify its needs. Failure to do this means it's at the mercy of the user's preference, as set by Java Or it's at the mercy of whatever IDE is launching it, using whatever launch mechanism the IDE uses.

    Depending on how the failing application is launched, you will have to do one of the following:
    1. In a shell or command-line, use the -d32 option.
    2. In a bundled app, remove the slice from the stub executable for the architecture NOT supported, leaving only the architecture that IS supported.

    If the Java application is launched via JNLP, there is a JNLP option for this. Refer to the JNLP spec and look for the arch options.

    If the Java application is launched by double-clicking a jar-file, then you have no control over the 32 or 64 bit arch. It will always follow the user's preference.

    An IDE is probably using a command-line or shell, but you should check the docs for the IDE. There should be a way to specify what the JVM launch options are for a project or target. These aren't necessarily the same as the JVM launch options for the IDE itself.

    Removal of a slice from the executable stub is done using the 'lipo' command.

    Reference for 'java' command, discussing -d32 and -d64:

Share This Page