Skip to content

Commit

Permalink
Fixes xerial#145: Use relative path to package
Browse files Browse the repository at this point in the history
  • Loading branch information
xerial committed Jan 5, 2017
1 parent de738f7 commit 27e3d90
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/main/java/org/sqlite/SQLiteJDBCLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
// SQLite.java
// Since: 2007/05/10
//
// $URL$
// $URL$
// $Author$
//--------------------------------------
package org.sqlite;
Expand Down Expand Up @@ -308,7 +308,8 @@ private static void loadSQLiteNativeLibrary() throws Exception {
}

// Load the os-dependent library from the jar file
sqliteNativeLibraryPath = "/org/sqlite/native/" + OSInfo.getNativeLibFolderPathForCurrentOS();
String packagePath = SQLiteJDBCLoader.class.getPackage().getName().replaceAll("\\.", "/");
sqliteNativeLibraryPath = String.format("/%s/native/%s", packagePath, OSInfo.getNativeLibFolderPathForCurrentOS());
boolean hasNativeLib = hasResource(sqliteNativeLibraryPath + "/" + sqliteNativeLibraryName);


Expand All @@ -325,12 +326,12 @@ private static void loadSQLiteNativeLibrary() throws Exception {

if(!hasNativeLib) {
extracted = false;
throw new Exception(String.format("No native library is found for os.name=%s and os.arch=%s", OSInfo.getOSName(), OSInfo.getArchName()));
throw new Exception(String.format("No native library is found for os.name=%s and os.arch=%s. path=%s", OSInfo.getOSName(), OSInfo.getArchName(), sqliteNativeLibraryPath));
}

// temporary library folder
String tempFolder = new File(System.getProperty("java.io.tmpdir")).getAbsolutePath();
// Try extracting the library from jar
// Try extracting the library from jar
if(extractAndLoadLibraryFile(sqliteNativeLibraryPath, sqliteNativeLibraryName, tempFolder)) {
extracted = true;
return;
Expand Down

0 comments on commit 27e3d90

Please sign in to comment.