0

So I've cloned the repo (https://github.com/techblue/jmagick), built, and copied the resulting two files to a directory:

/path/to/project/lib/jmagick-6.7.7.jar
/path/to/project/lib/libJMagick-6.7.7.so

I've also installed the latest ImageMagick, and since I'm on OSX, I did so with:

brew install imagemagick

I have version: imagemagick-6.9.3-6

When I run my application and first try to instantiate an ImageInfo object, I get the following exception:

java.lang.UnsatisfiedLinkError: no JMagick in java.library.path

And just a little more information, I built the code in the repository following the docker instructions, so it built in ubuntu. I don't know if that's a problem. I am not getting a class not found exception so I have to assume the jar is fine. My java.library.path looks like this:

"java.library.path" -> "/path/to/project/lib"

I'm about out of ideas and hair.

Programmer9000
  • 1,959
  • 3
  • 17
  • 27

1 Answers1

0

Well after a stupid amount of digging (this really ought to be better documented), I got it running.

You have to build it on the system you're going to use it on. If it's osx, you may (though I'm not sure this part is necessary) need to change the extension of the generated .so file to .dylib.

As I had, you must specify the following system property:

-Djava.library.path=/path/to/lib/file

That file MUST be named libJMagick.so or libJMagick.dylib. Java's classloader only looks for the name System.loadLibrary is give, and that name is jMagick in the jMagick jar. Lib is prepended (i'm guessing) by the classloader.

The only thing I never mentioned and will now in case anyone else was wondering how I added the jMagic.jar to the classpath:

   <dependency>
        <groupId>jmagick</groupId>
        <artifactId>jmagick</artifactId>
        <version>6.7.7</version>
        <scope>system</scope>
        <systemPath>/path/to/jar/jmagick-6.7.7.jar</systemPath>
    </dependency>

Good luck everybody

Programmer9000
  • 1,959
  • 3
  • 17
  • 27