I found this post How to copy files out of the currently running jar but because I am new to stackoverflow I can't comment there. The above post is mostly what I need but I receive an error while running it. I am also new to java and this error I believe is something simple but I can't figure it out. Here is my java code:
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
public class Test2 {
public static void main(String[] args) {
InputStream dllStream = Test2.class.getClassLoader().getResourceAsStream("/resources/jacob-1.18-x86.dll");
System.out.println(dllStream);
try {
FileOutputStream fos = new FileOutputStream("somelib.dll");
byte[] buf = new byte[2048];
int r=0;
while(-1 != (r = dllStream.read(buf))) {
fos.write(buf, 0, r);
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Here is a capture of my Eclipse resource folder + code:
Here is the error I'm receiving :
null
Exception in thread "main" java.lang.NullPointerException at Test2.main(Test2.java:23)
I know that I am receiving this error because something is null. My dllStream is null but I don't know why.
Please someone help this noob ^^^