Git Product home page Git Product logo

jar-loader's Introduction

Jar Loader

jar loader icon

What is it?

Easy migration to Java 9+ for applications that extend the class path by reflective access to the class loader.

Does your code work under Java 8 but fail under Java 9+ with an error stating that the system class loader is not an instance of URLClassLoader or that the method addURL could not be found? Then this is for you.

How to use it

Three steps:

  1. Add jar-loader.jar to your build libraries and application class path.
  2. Add -javaagent:path/to/jar-loader.jar to the VM options passed to the java command used to start your application.
  3. Where your code previously used reflection to invoke addURL on the system class loader, instead call ca.cgjennings.jvm.JarLoader.addToClassPath(File jarFile).

Notes

Jar Loader uses an official, documented method for extending the class path at runtime that has been supported since Java 6. It falls back to attempting reflective access if that fails. This method differs from URLClassLoader in that it only supports local JAR files. If your code relies on addURL to download code over a network, you will have to download it yourself and write it to a local file.

If you move the compiled JarLoader class to a different JAR file, it must include a MANIFEST.MF with the following line:

Premain-Class: ca.cgjennings.vm.JarLoader


Image credit: icon adapted from an icon by Eucalyp.

jar-loader's People

Contributors

cgjennings avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.