【发布时间】:2011-07-18 06:54:22
【问题描述】:
我正在尝试在 Java 中使用 System.load() 加载 DLL。我得到了这个例外:
什么意思?
编辑:
我的 jar 文件中有一些 dll。我将它们从 jar 文件中取出并使用以下代码将它们写入临时文件夹:
private static ArrayList buf;
public static InputStream soundStreams;
public static File getResourceFile(String resourceName, File dest)
{
InputStream is = null;
BufferedReader br = null;
int line;
ArrayList list = new ArrayList();
try
{
is = new Object().getClass().getResourceAsStream(resourceName);
br = new BufferedReader(new InputStreamReader(is));
while (-1 != (line = br.read()))
{
list.add(line);
}
}
catch (Exception e)
{
e.printStackTrace();
}
finally
{
try
{
if (br != null)
{
br.close();
}
if (is != null)
{
is.close();
}
File newFile = dest;
newFile.createNewFile();
FileOutputStream fos = new FileOutputStream(newFile);
for (Integer i : list)
{
fos.write(i.byteValue());
}
fos.close();
return newFile;
}
catch (IOException e)
{
e.printStackTrace();
}
}
return null;
}
然后我尝试使用 System.load(); 加载这个 dll;它会抛出异常。
【问题讨论】:
-
您使用的是 32 位 JVM 还是 64 位 JVM?
-
您正在尝试做的事情看起来几乎与stackoverflow.com/questions/1611357/…中接受的答案完全相同
-
@dcn 很酷,让我试试看效果如何