X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/ee6ffc12bf5523e4d2d2193138c791d991ec0ae4..e28a9a1f0dfaa7161fa5b5e65c4515afdd88b3b1:/src/bindings/java/org/simgrid/NativeLib.java diff --git a/src/bindings/java/org/simgrid/NativeLib.java b/src/bindings/java/org/simgrid/NativeLib.java index e2931c5a3d..4af8a637d9 100644 --- a/src/bindings/java/org/simgrid/NativeLib.java +++ b/src/bindings/java/org/simgrid/NativeLib.java @@ -19,15 +19,11 @@ public final class NativeLib { public static void nativeInit() { if (isNativeInited) return; - + if (System.getProperty("os.name").toLowerCase().startsWith("win")) NativeLib.nativeInit("winpthread-1"); - try { - NativeLib.nativeInit("boost_context"); - } catch (Exception e) {/* Dont care */} NativeLib.nativeInit("simgrid"); - NativeLib.nativeInit("surf-java"); NativeLib.nativeInit("simgrid-java"); isNativeInited = true; } @@ -36,15 +32,29 @@ public final class NativeLib { try { /* Prefer the version of the library bundled into the jar file and use it */ loadLib(name); - } catch (SimGridLibNotFoundException e) { + } catch (SimGridLibNotFoundException embeededException) { /* If not found, try to see if we can find a version on disk */ try { System.loadLibrary(name); - } catch (UnsatisfiedLinkError e2) { - System.err.println("Cannot load the bindings to the "+name+" library in path "+getPath()); - e.printStackTrace(); - System.err.println("This jar file does not seem to fit your system, and I cannot find an installation of SimGrid."); - System.exit(1); + } catch (UnsatisfiedLinkError systemException) { + if (! name.equals("boost_context")) { // Ignore when we cannot load boost_context + + System.err.println("\nCannot load the bindings to the "+name+" library in path "+getPath()); + Throwable cause = embeededException.getCause(); + if (cause instanceof java.lang.UnsatisfiedLinkError) { + if (cause.getMessage().matches(".*libcgraph.so.*")) + System.err.println("HINT: Try to install the libcgraph package (sudo apt-get install libcgraph)."); + else if (cause.getMessage().matches(".*libboost_context.so.*")) + System.err.println("HINT: Try to install the boost-context package (sudo apt-get install libboost-context-dev)."); + else + System.err.println("Try to install the missing dependencies, which name should appear above."); + } else { + System.err.println("This jar file does not seem to fit your system, and no usable SimGrid installation found on disk."); + } + System.err.println(); + cause.printStackTrace(); + System.exit(1); + } } } } @@ -118,10 +128,8 @@ public final class NativeLib { in.close(); out.close(); System.load(fileOut.getAbsolutePath()); - } catch (Exception e) { - System.err.println("Error while extracting the native library from the jar: "); - e.printStackTrace(); - throw new SimGridLibNotFoundException("Cannot load the bindings to the "+name+" library in path "+getPath(), e); + } catch (Throwable e) { + throw new SimGridLibNotFoundException("Cannot load the bindings to the "+name+" library in path "+getPath(), e); } } @@ -131,6 +139,7 @@ public final class NativeLib { public FileCleaner(File dir) { this.dir = dir; } + @Override public void run() { try { for (File f : dir.listFiles()) @@ -155,7 +164,7 @@ class SimGridLibNotFoundException extends Exception { super(msg); } - public SimGridLibNotFoundException(String msg, Exception e) { + public SimGridLibNotFoundException(String msg, Throwable e) { super(msg,e); } } \ No newline at end of file