Extracting DLL from JAR for use in JNI
From: Mark Osborn (ozziepeepsNOSPAM_at_yahoo.co.uk)
Date: 03/31/04
- Next message: Ondrej Hrabal: "Java 1.5 - Tiger"
- Previous message: Alasdair Dougall: "JSTL XML Transform losing tags"
- Next in thread: Chris Uppal: "Re: Extracting DLL from JAR for use in JNI"
- Reply: Chris Uppal: "Re: Extracting DLL from JAR for use in JNI"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 31 Mar 2004 03:35:56 -0800
Dear All,
I'm having trouble extracting a DLL file from a JAR file. The code I
give below used to work, but for some reason its broken now!
I've written an application that uses "plugins" shipped as JAR files.
When my main application instanciates a JAR file, it checks to see if
any native DLL's need to be extracted from the JAR to the plugin
folder, such that JNI calls can be made upon the DLL.
The code I have is as follows:
InputStream inputStream =
LeadToolsOCRPlugIn.class.getResourceAsStream("/mydll.dll");
FileOutputStream outputStream = new FileOutputStream(temporaryDll);
byte[] array = new byte[8192];
for (int i = inputStream.read(array); i != -1; i =
inputStream.read(array))
outputStream.write(array, 0, i);
outputStream.close();
The first line fails with NullPointerException - i.e. it cant find the
DLL inside the JAR, yet inspection of the JAR shows the DLL in the
root of the JAR file, and I've rebuilt the JAR many times in JBuilder
and all appears to be fine.
Any suggestions would be much appreciated! Either reply to the group,
or to my e-mail, removing the bit in CAPITALS.
Cheers,
Mark
- Next message: Ondrej Hrabal: "Java 1.5 - Tiger"
- Previous message: Alasdair Dougall: "JSTL XML Transform losing tags"
- Next in thread: Chris Uppal: "Re: Extracting DLL from JAR for use in JNI"
- Reply: Chris Uppal: "Re: Extracting DLL from JAR for use in JNI"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|