File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
runtime/src/main/java/com4j Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -542,6 +542,8 @@ private static void loadNativeLibrary() {
542542 cause = t ;
543543 }
544544
545+ final String fileName = "com4j-" + System .getProperty ("os.arch" ) + ".dll" ;
546+
545547 // try loading com4j.dll in the same directory as com4j.jar
546548 URL res = COM4J .class .getClassLoader ().getResource ("com4j/COM4J.class" );
547549 String url = res .toExternalForm ();
@@ -567,7 +569,6 @@ private static void loadNativeLibrary() {
567569 e .printStackTrace ();
568570 }
569571 File jarFile = new File (filePortion );
570- String fileName = "com4j-" + System .getProperty ("os.arch" ) + ".dll" ;
571572 File dllFile = new File (jarFile .getParentFile (), fileName );
572573 if (!dllFile .exists ()) {
573574 // try to extract from within the jar
@@ -582,8 +583,15 @@ private static void loadNativeLibrary() {
582583 System .load (dllFile .getPath ());
583584 return ;
584585 }
586+ } else
587+ if (url .startsWith ("file:" )) {
588+ File classFile = new File (url .substring (5 ));
589+ File dllFile = new File (classFile .getParentFile (),fileName );
590+ System .load (dllFile .getPath ());
591+ return ;
585592 }
586593
594+
587595 UnsatisfiedLinkError error = new UnsatisfiedLinkError ("Unable to load com4j.dll" );
588596 error .initCause (cause );
589597 throw error ;
You can’t perform that action at this time.
0 commit comments