小さな問題があります。私はJavaSEを学び、クラスClassLoaderを見つけました。以下のコードで使用しようとしています。URLClassLoaderを使用して、実行時にクラスを動的にロードしようとしています。
URLClassLoader urlcl = new URLClassLoader(new URL[] {new URL("file:///I:/Studia/PW/Sem6/_repozytorium/workspace/Test/testJavaLoader.jar")});
Class<?> classS = urlcl.loadClass("michal.collection.Stack");
for(Method field: classS.getMethods()) {
System.out.println(field.getName());
}
Object object = classS.newInstance();
michal.collection.Stack new_name = (michal.collection.Stack) object;
Java仮想マシンはクラスを認識せず、次の例外が発生します。
Exception in thread "main" java.lang.Error: Unresolved compilation problems: michal cannot be resolved to a type michal cannot be resolved to a type at Main.main(Main.java:62)
私がこの問題を解決する方法を知っていますか?