Advertisement
DizzyFoxkit

Path curiosity

Jan 26th, 2016
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1.  11     try {
  2.  12             System.out.print("Path before modification: "); // checking to make sure there is a path
  3.  13             String currentPath = System.getProperty("java.library.path"); // getting currently set path
  4.  15             String newPath = "/usr/share/java/mariadb-jdbc/mariadb-java-client.jar:    " + currentPath; // creating a new path by string concatnation
  5.  18             System.setProperty("java.library.path", newPath); // replacing path with newPath
  6.  19             System.out.print("Path after modification: ");
  7.  20             System.out.println(System.getProperty("Java.library.path")); // Prints out as null
  8.  21
  9.  22             Field fieldSysPath = ClassLoader.class.getDeclaredField("sys_paths");
  10.  23             fieldSysPath.setAccessible(true);
  11.  24             fieldSysPath.set(null, null);
  12.  25         } catch (NoSuchFieldException|IllegalAccessException ex) {
  13.  26             Logger lgr = Logger.getLogger(Prepared.class.getName());
  14.  27             lgr.log(Level.SEVERE, ex.getMessage(), ex);
  15.  28         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement