# File lib/buildr/java/jruby.rb, line 93
    def load
      return self if @loaded

      # Adding jars to the jruby's $CLASSPATH should be the correct thing, however it
      # seems like some tools require their jars on system class loader (javadoc, junit, etc)
      # cp.each { |path| $CLASSPATH << path }

      # Use system ClassLoader to add classpath
      sysloader = java.lang.ClassLoader.getSystemClassLoader
      add_url_method = java.lang.Class.forName('java.net.URLClassLoader').
        getDeclaredMethod('addURL', [java.net.URL.java_class].to_java(java.lang.Class))
      add_url_method.setAccessible(true)
      add_path = lambda { |path| add_url_method.invoke(sysloader, [java.io.File.new(path).toURI.toURL].to_java(java.net.URL)) }

      # Most platforms requires tools.jar to be on the classpath.
      add_path[tools_jar] if tools_jar

      classpath.map! { |path| Proc === path ? path.call : path }
      Buildr.artifacts(classpath).map(&:to_s).each do |path|
        file(path).invoke
        add_path[path]
      end

      @loaded = true
      self
    end