Skip to main content

JDIC code fails to get path for Linux libs in Web Start...

No replies
tdanecito
Offline
Joined: 2005-10-10

Hi,

I have some libraries where I have to know the path to them in java web start. The problem is the code works great in Windows but not for Ubuntu 9.1. There I get a null for the findLibrary call shown below. Any hints what Might be wrong? Anyone know an easier way to get the path to the jars in Web Start?

class JNLPClassLoaderAccessor {
static java.lang.reflect.Method mdJNLPClassLoader_findLibrary = null;
static {
java.security.AccessController
.doPrivileged(new java.security.PrivilegedAction() {
public Object run() {
try {
mdJNLPClassLoader_findLibrary = Class.forName(
"com.sun.jnlp.JNLPClassLoader")
.getDeclaredMethod("findLibrary",
new Class[] { String.class });
mdJNLPClassLoader_findLibrary.setAccessible(true);
} catch (Exception e) {
e.printStackTrace();
}
// to please javac
return null;
}
});
}

public static String findLibrary(JNLPClassLoader o, String name) {
try {
return (String) mdJNLPClassLoader_findLibrary.invoke(o,
new Object[] { name });
} catch (Exception e) {
e.printStackTrace();
}
return null;
}

}