If running web start, determine the location of a given native library. This value may be used to properly set jna.library.path so that JNA can load libraries identified by the <nativelib> tag in the JNLP configuration file. Returns null if the Web Start native libr
(final String libName)
| 1341 | * @return null if unable to query the web start loader. |
| 1342 | */ |
| 1343 | public static String getWebStartLibraryPath(final String libName) { |
| 1344 | if (System.getProperty("javawebstart.version") == null) |
| 1345 | return null; |
| 1346 | try { |
| 1347 | |
| 1348 | final ClassLoader cl = Native.class.getClassLoader(); |
| 1349 | Method m = (Method) accessControllerDoPrivileged.invoke(null, new PrivilegedAction<Method>() { |
| 1350 | @Override |
| 1351 | public Method run() { |
| 1352 | try { |
| 1353 | Method m = ClassLoader.class.getDeclaredMethod("findLibrary", new Class[] { String.class }); |
| 1354 | m.setAccessible(true); |
| 1355 | return m; |
| 1356 | } |
| 1357 | catch(Exception e) { |
| 1358 | return null; |
| 1359 | } |
| 1360 | } |
| 1361 | }); |
| 1362 | String libpath = (String)m.invoke(cl, new Object[] { libName }); |
| 1363 | if (libpath != null) { |
| 1364 | return new File(libpath).getParent(); |
| 1365 | } |
| 1366 | return null; |
| 1367 | } |
| 1368 | catch (Throwable e) { |
| 1369 | return null; |
| 1370 | } |
| 1371 | } |
| 1372 | |
| 1373 | /** Perform cleanup of automatically unpacked native shared library. |
| 1374 | */ |