private static void resetJavaLibraryPath ( ) { synchronized ( Runtime . getRuntime ( ) ) { try { Field field = ClassLoader . class . getDeclaredField ( "usr_paths" ) ; field . setAccessible ( true ) ; field . set ( null , null ) ; field = ClassLoader . class . getDeclaredField ( "sys_paths" ) ; field . setAccessible ( true ) ; field . set ( null , null ) ; } catch ( NoSuchFieldException e ) { throw new RuntimeException ( e ) ; } catch ( IllegalAccessException e ) { throw new RuntimeException ( e ) ; } } }
Delete the cache of java . library . path . This will force the classloader to recheck the modified value the next time we load libraries .