diff --git a/ChangeLog.txt b/ChangeLog.txt index 4862be38..c4c5ddc9 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -22,6 +22,9 @@ symlinks in /usr/lib/i386-linux-gnu for the TurboJPEG libraries in /usr/lib32. This allows those libraries to be used on MultiArch-compatible systems (such as Ubuntu 11 and later) without setting the linker path. +[6] The TurboJPEG Java wrapper should now find the JNI library on Mac systems +without having to pass -Djava.library.path=/usr/lib to java. + 1.2.1 ===== diff --git a/java/README b/java/README index 22e0f738..8bca0710 100644 --- a/java/README +++ b/java/README @@ -34,22 +34,10 @@ compressing or decompressing consists of images of the same size, then pre-allocating the buffers is recommended. -Note for OS X users -------------------- - -/usr/lib, the directory under which libturbojpeg.dylib is installed on Mac -systems, is not part of the normal Java library path. Thus, when running a -Java application that uses TurboJPEG/OSS on Mac systems, you will need to pass -an argument of -Djava.library.path=/usr/lib to java. - - -Note for Solaris users +Installation Directory ---------------------- -/opt/libjpeg-turbo/lib, the directory under which libturbojpeg.so is installed -on Solaris systems, is not part of the normal Java library path. Thus, when -running a Java application that uses TurboJPEG/OSS on Solaris systems, you will -need to pass an argument of -Djava.library.path=/opt/libjpeg-turbo/lib to java. -If using a 64-bit data model, then instead pass an argument of --Djava.library.path=/opt/libjpeg-turbo/lib/amd64 to use the 64-bit version of -libturbojpeg.so. +If the TurboJPEG JNI library (libturbojpeg.so, libturbojpeg.jnilib, or +turbojpeg.dll) is not installed under a system library directory or under a +directory specified in LD_LIBRARY_PATH (Unix) or PATH (Windows), then you will +need to pass an argument of -Djava.library.path={path_to_JNI_library} to java. diff --git a/java/org/libjpegturbo/turbojpeg/TJLoader.java b/java/org/libjpegturbo/turbojpeg/TJLoader.java index db77bbae..ded963ea 100644 --- a/java/org/libjpegturbo/turbojpeg/TJLoader.java +++ b/java/org/libjpegturbo/turbojpeg/TJLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (C)2011 D. R. Commander. All Rights Reserved. + * Copyright (C)2011-2012 D. R. Commander. All Rights Reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: @@ -30,6 +30,14 @@ package org.libjpegturbo.turbojpeg; final class TJLoader { static void load() { - System.loadLibrary("turbojpeg"); + try { + System.loadLibrary("turbojpeg"); + } catch (java.lang.UnsatisfiedLinkError e) { + String os = System.getProperty("os.name").toLowerCase(); + if (os.indexOf("mac") >= 0) { + System.load("/usr/lib/libturbojpeg.jnilib"); + } + else throw e; + } } };