diff --git a/ortools/java/com/google/ortools/Loader.java b/ortools/java/com/google/ortools/Loader.java index 457ab82d53..9bdb8b0751 100644 --- a/ortools/java/com/google/ortools/Loader.java +++ b/ortools/java/com/google/ortools/Loader.java @@ -29,6 +29,8 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.Collections; import java.util.List; +import java.util.Map; +import java.util.AbstractMap; import java.util.Objects; /** Load native libraries needed for using ortools-java. */ @@ -141,19 +143,30 @@ public class Loader { try { URI resourceURI = getNativeResourceURI(); Path tempPath = unpackNativeResources(resourceURI); - // libraries order does matter ! - List dlls = Arrays.asList("zlib1", "abseil_dll", "re2", "utf8_validity", - "libprotobuf", "highs", "libscip", "ortools", "jniortools"); - for (String dll : dlls) { + // libraries order does matter ! + List> dlls = Arrays.asList( + (new AbstractMap.SimpleEntry("zlib1", true)), + (new AbstractMap.SimpleEntry("abseil_dll", true)), + (new AbstractMap.SimpleEntry("re2", true)), + (new AbstractMap.SimpleEntry("libutf8_validity", true)), + (new AbstractMap.SimpleEntry("libprotobuf", true)), + (new AbstractMap.SimpleEntry("highs", false)), + (new AbstractMap.SimpleEntry("libscip", false)), + (new AbstractMap.SimpleEntry("ortools", true)), + (new AbstractMap.SimpleEntry("jniortools", true))); + + for (Map.Entry dll : dlls) { try { - // System.out.println("System.load(" + dll + ")"); + //System.out.println("System.load(" + dll.getKey() + ")"); System.load(tempPath.resolve(RESOURCE_PATH) - .resolve(System.mapLibraryName(dll)) + .resolve(System.mapLibraryName(dll.getKey())) .toAbsolutePath() .toString()); } catch (UnsatisfiedLinkError e) { - System.out.println("System.load(" + dll + ") failed!"); - throw new RuntimeException(e); + System.out.println("System.load(" + dll.getKey() + ") failed!"); + if(dll.getValue()) { + throw new RuntimeException(e); + } } } loaded = true;