Created
May 26, 2020 01:58
-
-
Save TsuyoshiUshio/6d8d41addb4afd22fdebd8333aef8323 to your computer and use it in GitHub Desktop.
GraalVM sample
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.lang.reflect.Method; | |
import java.net.URL; | |
import java.net.URLClassLoader; | |
public class Main { | |
public static void main(String args[]){ | |
try{ | |
String pathToJar = args[0]; | |
System.out.println(pathToJar); | |
URL[] urls = { new URL("jar:file:" + pathToJar+"!/")}; | |
URLClassLoader cl = URLClassLoader.newInstance(urls); | |
Class<?> lib = cl.loadClass("com.simplearchitect.lib.LibrarySample"); | |
Object sample = lib.getDeclaredConstructor().newInstance(); | |
System.out.println(lib.getName()); | |
Method execute =lib.getMethod("execute"); | |
execute.invoke(sample); | |
} catch (Exception e) { | |
e.printStackTrace(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment