Пример #1
0
 static {
   System.load(
       (new File("/home/gathors/proj/v-opencv/FeatureMatching/libs/libopencv_java2412.so"))
           .getAbsolutePath());
   System.load(
       (new File("/home/gathors/proj/v-opencv/FeatureMatching/libs/libopencv_highgui.so"))
           .getAbsolutePath());
 }
Пример #2
0
  @Override
  public boolean loadLibrary(String libname, boolean ignoreError, ClassLoader cl) {
    try {
      for (Entry<String, String> nativeEntry : platformNativeIndex.entrySet()) {
        if (nativeEntry.getKey().contains(libname)) {
          if (log.isDebugEnabled()) {
            log.debug(
                "Loading mapped entry: [{}] [{}] [{}]",
                libname,
                nativeEntry.getKey(),
                nativeEntry.getValue());
          }
          File nativeLibCopy =
              extractJarEntry(
                  nativeEntry.getValue(),
                  nativeEntry.getKey(),
                  System.getProperty(JAVA_TMP_DIR),
                  String.format("%s.jni", libname));
          System.load(nativeLibCopy.getAbsolutePath());
          return true;
        }
      }
    } catch (Exception e) {
      log.error("Unable to load native library [{}] - {}", libname, e);
    }

    if (log.isDebugEnabled()) {
      log.debug("No mapped library match for [{}]", libname);
    }
    return false;
  }
Пример #3
0
 static boolean loadNSPR(String libdir) throws Exception {
   // load NSS softoken dependencies in advance to avoid resolver issues
   try {
     System.load(libdir + System.mapLibraryName(NSPR_PREFIX + "nspr4"));
   } catch (UnsatisfiedLinkError e) {
     // GLIBC problem on older linux-amd64 machines
     if (libdir.contains("linux-amd64")) {
       System.out.println(e);
       System.out.println("NSS does not work on this platform, skipping.");
       return false;
     }
     throw e;
   }
   System.load(libdir + System.mapLibraryName(NSPR_PREFIX + "plc4"));
   System.load(libdir + System.mapLibraryName(NSPR_PREFIX + "plds4"));
   return true;
 }
Пример #4
0
 static {
   String path = "";
   try {
     path = new File("Teste13native.dll").getCanonicalPath().toString();
     System.out.println(path);
   } catch (Exception e) {
     System.out.println(e);
   }
   // System.loadLibrary("Teste13native");
   System.load(path);
 }
Пример #5
0
 private static void extractAndLoadNativeLib(String nativeLibName, Path target) {
   //		System.err.println("loading "+nativeLibName);
   final Path path = Paths.get(target.toString(), nativeLibName);
   if (!path.toFile().exists()) {
     try (InputStream is =
         CudaEngine.class
             .getClassLoader()
             .getResourceAsStream("/lib/" + nativeLibName)) { // TODO TK property for lib dir
       Files.copy(is, path);
     } catch (IOException e) {
       e.printStackTrace();
     } catch (NullPointerException e) { // TODO find a way to do it instead of eclipse
       final Path eclipsePath = FileSystems.getDefault().getPath("lib", nativeLibName);
       try {
         Files.copy(eclipsePath, path);
       } catch (IOException e1) {
         // TODO Auto-generated catch block
         e1.printStackTrace();
       }
     }
   }
   System.load(path.toString());
   //		System.load(nativeLibName);
 }