Results 1 to 6 of 6
Thread: [Applet] Set java.library.path
- 02-21-2011, 09:01 AM #1
[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:
The applet uses the java.library.path given in the startup command.Java 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
But I want to let it work in each browser.
java-code:
html-code:Java 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); } } }
java.policy.appletJava Code:<applet code="loader.class" archive="loader.jar" width="1000" height="500"></applet>
I use the IDE Eclipse for create and test it at the most times.Java Code:/* AUTOMATICALLY GENERATED ON Tue Apr 16 17:20:59 EDT 2002*/ /* DO NOT EDIT */ grant { permission java.security.AllPermission; };
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
- 02-21-2011, 10:42 AM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
The clients that want to use it will have to change their configurations.
- 02-21-2011, 10:48 AM #3
But I can sign the jar, so they have to accept the applet to run.
And I only want to set this changes temporary, only while the applet is running and only used by applet.
- 02-21-2011, 11:05 AM #4
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Doesn't matter. The library path needs to be set before the JVM is started in the browser. By the time it gets to the Applet, its too late. The clients will need to change their configuration.
- 02-21-2011, 01:01 PM #5
Okay,
But then it is quite strange that there is an function:PJava Code:System.setPropery("java.library.path", "...");
Thank you for your help, I'll look for another way to let it work.
- 02-21-2011, 01:12 PM #6
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
No, it's not quite strange. However, that particular system property is there for "informational" purposes only. That property list is nothing but a list of Strings from values that were set before the program started. There is no guarantee that any of those will be "looked at" and used dynamically. most of them will have been read and their value saved and won't be looked at again (by the JVM, but maybe by you).
Similar Threads
-
How to place the DLL file in java.library.path??
By miu44 in forum NetBeansReplies: 2Last Post: 02-03-2011, 03:06 AM -
setting class-path & Library Path in ubantu
By programmer_007 in forum EclipseReplies: 18Last Post: 02-22-2010, 12:31 PM -
java.library.path problems
By deepthought in forum New To JavaReplies: 1Last Post: 02-15-2010, 08:06 AM -
URGENT: How to include a library in Java class path?
By gsmurthy30 in forum New To JavaReplies: 3Last Post: 09-15-2008, 04:58 PM -
URGENT: How to include a library in Java class path?
By gsmurthy30 in forum Advanced JavaReplies: 1Last Post: 09-15-2008, 08:39 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks