java 目录分隔符不应出现在库名称中:Macintosh HD/Users/sakkisetty/Documents/dll/FasExtend.dll
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15758095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Directory separator should not appear in library name: Macintosh HD/Users/sakkisetty/Documents/dll/FasExtend.dll
提问by somesh
I use to load the dll library in java program it . show the error. like this Directory separator should not appear in library name:.
我用来在java程序中加载dll库。显示错误。像这样 目录分隔符不应出现在库名中:。
import java.sql.*;
/*
import com.sun.jna.Library;
import com.sun.jna.Native;
import com.sun.jna.NativeLong;
import com.sun.jna.Platform;
import com.sun.jna.*;*/
public class jdbc3
{
public native void FasSendUserFromFasToFac();
static
{
System.loadLibrary("Macintosh HD/Users/sakkisetty/Documents/dll/FasExtend");
}
/* public interface simpleDLL extends Library
{
simpleDLL INSTANCE = (simpleDLL) Native.loadLibrary((Platform.isWindows() ? "simpleDLL" : "simpleDLLLinuxPort"), simpleDLL.class);
byte giveVoidPtrGetChar(Pointer param); // char giveVoidPtrGetChar(void* param);
int giveVoidPtrGetInt(Pointer param); //int giveVoidPtrGetInt(void* param);
int giveIntGetInt(int a); // int giveIntGetInt(int a);
void simpleCall();
}*/
// JDBC driver name and database URL
static final String JDBC_DRIVER = "com.mysql.jdbc.Driver";
static final String DB_URL = "jdbc:mysql://localhost:3306/somesh";
// Database credentials
static final String USER = "root";
static final String PASS = "";
public static void main(String[] args)
{
jdbc3 jb=new jdbc3();
jb.FasSendUserFromFasToFac();
Connection conn = null;
Statement stmt = null;
try{
//STEP 2: Register JDBC driver
Class.forName("com.mysql.jdbc.Driver");
//STEP 3: Open a connection
// System.out.println("Connecting to database...");
conn = DriverManager.getConnection(DB_URL,USER,PASS);
System.out.println("Connecting to database...");
//STEP 4: Execute a query
System.out.println("Creating statement...");
stmt = conn.createStatement();
String sql;
sql = " select id,image from images1 ";
ResultSet rs = stmt.executeQuery(sql);
//STEP 5: Extract data from result set
while(rs.next())
{
//Retrieve by column name
System.out.println("\n");
int no = rs.getInt("id");
System.out.print("\t USER_I_ID: " +no);
/*String std_name = rs.getString("name");
System.out.print(" \t First_name : " + std_name);
String std_course = rs.getString("course");
System.out.print(" \t course : " + std_course);*/
Blob std_image = rs.getBlob("image");
System.out.print(" \t std_images : SS" + std_image);
}
}
catch(SQLException se)
{
//Handle errors for JDBC
se.printStackTrace();
}catch(Exception e)
{
//Handle errors for Class.forName
e.printStackTrace();
}finally
{
//finally block used to close resources
try{
if(stmt!=null)
stmt.close();
}catch(SQLException se2){
}// nothing we can do
try{
if(conn!=null)
conn.close();
}catch(SQLException se){
se.printStackTrace();
}//end catch try
}//end finally
}//end main
}//end FirstExample
suppose i use the only system.load()
it may show one type error . that is
假设我只使用system.load()
它可能会显示一种类型的错误。那是
Expecting an absolute path of the library: Macintosh HD/Users/sakkisetty/Documents/dll/FasExtend.dll
and use the full name system.loadlibrary()
. it may show another type error. that is
并使用全名system.loadlibrary()
。它可能会显示另一种类型的错误。那是
Exception in thread "main" java.lang.UnsatisfiedLinkError:
Directory separator should not appear in library name:
Macintosh HD/Users/sakkisetty/Documents/dll/FasExtend.dll
so i am using mac OS. please tell me solution for this problem.
所以我使用的是 mac 操作系统。请告诉我这个问题的解决方案。
回答by rdmcfee
System.loadLibrary only accepts a filename and looks for the file in the current java paths available. You'll want to add the directory containing FasExtend.dll to your java path, then just use
System.loadLibrary 只接受文件名并在当前可用的 java 路径中查找文件。您需要将包含 FasExtend.dll 的目录添加到您的 java 路径中,然后只需使用
System.loadLibrary("FasExtend")
Similar to this post: Java native library System.loadLibrary fails with UnsatisfiedLinkError
类似于这篇文章:Java 本地库 System.loadLibrary 因 UnsatisfiedLinkError 失败