We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ee52288 commit bf86c46Copy full SHA for bf86c46
1 file changed
01jvm/TestAddUrl.java
@@ -0,0 +1,26 @@
1
+package io.kimmking.kmq;
2
+
3
+import lombok.SneakyThrows;
4
5
+import java.io.File;
6
+import java.lang.reflect.Method;
7
+import java.net.URL;
8
+import java.net.URLClassLoader;
9
10
+public class TestAddUrl {
11
12
+ @SneakyThrows
13
+ public static void main(String[] args) {
14
+ URLClassLoader classLoader = (URLClassLoader) TestAddUrl.class.getClassLoader();
15
+ String dir = "/Users/kimmking/Downloads/Hello";
16
+ Method method = URLClassLoader.class.getDeclaredMethod("addURL", URL.class);
17
+ method.setAccessible(true);
18
+ method.invoke(classLoader, new File(dir).toURL());
19
20
+ Class klass = Class.forName("Hello",true, classLoader);
21
+ Object obj = klass.newInstance();
22
+ Method hello = klass.getDeclaredMethod("hello");
23
+ hello.invoke(obj);
24
+ }
25
26
+}
0 commit comments