프로그램 용 API 시스템에서 작업 중입니다. 이 시스템은 '플러그인'폴더로 이동하여 모든 항아리를로드합니다. 'plugin'폴더에있는 jar 파일의 기본 클래스를로드하려고 시도하지만 그렇게하는 동안 ClassNotFoundException이 발생합니다. 질문이 모호하고 불분명jar 파일을로드 할 때 Java 클래스를 찾을 수 없습니다.
private static void loadClassFromJar(String PluginJar) throws MalformedURLException, ClassNotFoundException, InstantiationException, IllegalAccessException, NoSuchMethodException, SecurityException, IllegalArgumentException, InvocationTargetException {
logger.debug("jar:file:" + "./debug/plugins/DiamondCorePlugin.jar!/");
URL[] urls = { new URL("jar:file:" + FileList.PluginFolder.getAbsolutePath() + PluginJar +"!/") };
URLClassLoader ClassLoader = URLClassLoader.newInstance(urls);
Class<?> Class = ClassLoader.loadClass("net.trenterprises.diamondcore.plugin.Main");
Object Object = Class.newInstance();
Method EventMethod = Object.getClass().getMethod("onEnable");
EventMethod.invoke(Object);
}
있으면 알려 주시기 바랍니다 (I 여기 주위에 새로운 오전, 그래서 난 내에 가장 단어를 물어 질문을보십시오) :
여기 내 코드입니다.
편집 : 스택 추적을 잊어 버렸습니다. 여기있어!
java.lang.ClassNotFoundException: net.trenterprises.diamondcore.plugin.Main
at java.net.URLClassLoader$1.run(URLClassLoader.java:372)
at java.net.URLClassLoader$1.run(URLClassLoader.java:361)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:360)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.net.FactoryURLClassLoader.loadClass(URLClassLoader.java:798)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at net.trenterprises.diamondcore.cross.api.PluginLoader.loadClassFromJar(PluginLoader.java:53)
at net.trenterprises.diamondcore.cross.api.PluginLoader.loadAllPlugins(PluginLoader.java:25)
at net.trenterprises.diamondcore.DiamondCoreServer.<init>(DiamondCoreServer.java:47)
at net.trenterprises.diamondcore.run.main(run.java:15)
''enterprises' –