[Applet] Set java.library.path
I wanna load an "*.dll" file in java, but I've read that I have to set an "java.library.path".
Now when I set the java.library.path in the applet self it won't use it.
When I use the appletviewer and set the java.library.path with the command:
Code:
appletviewer -J-Djava.security.policy=java.policy.applet -J-Djava.library.path=D:/java_libraries/j3d-1_5_2-windows-i586/bin index.html
The applet uses the java.library.path given in the startup command.
But I want to let it work in each browser.
java-code:
Code:
import java.awt.Color;
import java.awt.Graphics;
public class loader extends java.applet.Applet
{
private String oldJLP;
private String oldUD;
private boolean error = false;
private String message;
public void init()
{
oldJLP=System.getProperty("java.library.path");
oldUD=System.getProperty("user.dir");
System.setProperty("java.library.path", "D:\\java_libraries\\j3d-1_5_2-windows-i586\\bin");
System.setProperty("user.dir", "D:\\java_libraries\\j3d-1_5_2-windows-i586\\bin");
try{
System.loadLibrary("j3dcore-d3d");
message = "j3dcore-d3d loaded";
}catch(UnsatisfiedLinkError ex){
error=true;
message = ex.getMessage();
}
}
public void paint(Graphics g)
{
g.drawString("old-JLP: " + oldJLP, 10, 10);
g.drawString("new-JLP: " + System.getProperty("java.library.path"), 10, 30);
g.drawString("old-UD: " + oldUD, 10, 50);
g.drawString("new-UD: " + System.getProperty("user.dir"), 10, 70);
if(error){
g.setColor(Color.red);
g.drawString("message: " + message, 10, 90);
}else{
g.setColor(Color.green);
g.drawString("message: " + message, 10, 90);
}
}
}
html-code:
Code:
<applet code="loader.class" archive="loader.jar" width="1000" height="500"></applet>
java.policy.applet
Code:
/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/
/* DO NOT EDIT */
grant {
permission java.security.AllPermission;
};
I use the IDE Eclipse for create and test it at the most times.
The "j3dcore-d3d" is in "D:\java_libraries\j3d-1_5_2-windows-i586\bin".
Does someone know how I can set the java.library.path while the applet is running, tell me!
Thanks,
Dennis