2
java.lang.reflect.Field field = ClassLoader.class.getDeclaredField("usr_paths");
field.setAccessible(true);
String[] paths = (String[])field.get(null);
当使用Tomcat时,我可以得到'java.library.path'。但是,当使用IBM WebSphere时,不起作用。 指定的财产是错误的?
地址:如何获得“usr_paths”字段?
ClassLoader.class.getDeclaredFields();
我找不到 “usr_paths”。
你有什么异常/错误?或者它只是不返回任何东西?还有你应该担心的任何安全问题? – acostache
我认为您可能会遇到由于Tomcat与WebSphere JVM交互(和/或安全问题:您的服务器可能没有足够的权限或类似访问JVM的问题)而产生的问题 – acostache
此外,正如此链接中所述(http://nicklothian.com/blog/2008/11/19/modify-javalibrarypath-at-runtime/)以及此代码在搜索时显示的其他相关位置,这可能无法在所有平台上移植 – acostache