summaryrefslogtreecommitdiff
path: root/demos
diff options
context:
space:
mode:
authorEthan Vrhel <ethanvrhel@gmail.com>2021-08-30 13:07:47 -0700
committerEthan Vrhel <ethanvrhel@gmail.com>2021-08-30 13:24:44 -0700
commit7677c955cc5ba202fb93d5d2e3948dc3ce196759 (patch)
tree93d477eec5bf0405a6d07b2cb593c85a864fc66a /demos
parent27a1e3a5ed1390dd1e5f59e297532bfb08a915ee (diff)
downloadghostpdl-7677c955cc5ba202fb93d5d2e3948dc3ce196759.tar.gz
Updated how native libraries load
Fixed compiler errors in GSAPI.java and NativePointer.java Fixed whitespace issues
Diffstat (limited to 'demos')
-rw-r--r--demos/java/gsjava/src/com/artifex/gsjava/GSAPI.java30
-rw-r--r--demos/java/gsjava/src/com/artifex/gsjava/util/NativePointer.java30
2 files changed, 38 insertions, 22 deletions
diff --git a/demos/java/gsjava/src/com/artifex/gsjava/GSAPI.java b/demos/java/gsjava/src/com/artifex/gsjava/GSAPI.java
index 52d238a5c..652d43562 100644
--- a/demos/java/gsjava/src/com/artifex/gsjava/GSAPI.java
+++ b/demos/java/gsjava/src/com/artifex/gsjava/GSAPI.java
@@ -30,18 +30,26 @@ public class GSAPI {
* Registers the needed native libraries.
*/
private static void registerLibraries() {
- if (System.getProperty("os.name").equalsIgnoreCase("Linux")) {
- File libgpdl = new File("libgpdl.so");
- System.load(libgpdl.getAbsolutePath());
- File gsjni = new File("gs_jni.so");
- System.load(gsjni.getAbsolutePath());
- } else if (System.getProperty("os.name").equalsIgnoreCase("Mac OS X")) {
- File libgpdl = new File("libgpdl.dylib");
- System.load(libgpdl.getAbsolutePath());
- File gsjni = new File("gs_jni.dylib");
- System.load(gsjni.getAbsolutePath());
- } else {
+ try {
+ // Try loading normally
System.loadLibrary("gs_jni");
+ } catch (UnsatisfiedLinkError e) {
+ // Load using absolute paths
+ if (System.getProperty("os.name").equalsIgnoreCase("Linux")) {
+ // Load on Linux
+ File libgpdl = new File("libgpdl.so");
+ System.load(libgpdl.getAbsolutePath());
+ File gsjni = new File("gs_jni.so");
+ System.load(gsjni.getAbsolutePath());
+ } else if (System.getProperty("os.name").equalsIgnoreCase("Mac OS X")) {
+ // Load on Mac
+ File libgpdl = new File("libgpdl.dylib");
+ System.load(libgpdl.getAbsolutePath());
+ File gsjni = new File("gs_jni.dylib");
+ System.load(gsjni.getAbsolutePath());
+ } else {
+ throw e;
+ }
}
}
diff --git a/demos/java/gsjava/src/com/artifex/gsjava/util/NativePointer.java b/demos/java/gsjava/src/com/artifex/gsjava/util/NativePointer.java
index 444103772..efe1a3e7c 100644
--- a/demos/java/gsjava/src/com/artifex/gsjava/util/NativePointer.java
+++ b/demos/java/gsjava/src/com/artifex/gsjava/util/NativePointer.java
@@ -33,18 +33,26 @@ public class NativePointer {
* Registers the needed native libraries.
*/
private static void registerLibraries() {
- if (System.getProperty("os.name").equalsIgnoreCase("Linux")) {
- File libgpdl = new File("libgpdl.so");
- System.load(libgpdl.getAbsolutePath());
- File gsjni = new File("gs_jni.so");
- System.load(gsjni.getAbsolutePath());
- } else if (System.getProperty("os.name").equalsIgnoreCase("Mac OS X")) {
- File libgpdl = new File("libgpdl.dylib");
- System.load(libgpdl.getAbsolutePath());
- File gsjni = new File("gs_jni.dylib");
- System.load(gsjni.getAbsolutePath());
- } else {
+ try {
+ // Try loading normally
System.loadLibrary("gs_jni");
+ } catch (UnsatisfiedLinkError e) {
+ // Load using absolute paths
+ if (System.getProperty("os.name").equalsIgnoreCase("Linux")) {
+ // Load on Linux
+ File libgpdl = new File("libgpdl.so");
+ System.load(libgpdl.getAbsolutePath());
+ File gsjni = new File("gs_jni.so");
+ System.load(gsjni.getAbsolutePath());
+ } else if (System.getProperty("os.name").equalsIgnoreCase("Mac OS X")) {
+ // Load on Mac
+ File libgpdl = new File("libgpdl.dylib");
+ System.load(libgpdl.getAbsolutePath());
+ File gsjni = new File("gs_jni.dylib");
+ System.load(gsjni.getAbsolutePath());
+ } else {
+ throw e;
+ }
}
}