Skip to content

Instantly share code, notes, and snippets.

@dacr
Created April 27, 2014 07:59
Show Gist options
  • Save dacr/11340087 to your computer and use it in GitHub Desktop.
Save dacr/11340087 to your computer and use it in GitHub Desktop.
def addLibraryPath(pathToAdd: String) {
import java.lang.reflect.Field
val usrPathsField: Field = classOf[ClassLoader].getDeclaredField("usr_paths")
usrPathsField.setAccessible(true)
val paths = usrPathsField.get(null).asInstanceOf[Array[String]]
if (!paths.contains(pathToAdd)) {
usrPathsField.set(null, paths :+ pathToAdd)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment