swt - Java load jar after runtime does not work correctly -



swt - Java load jar after runtime does not work correctly -

when load swt jar code this post, exception:

exception in thread "main" java.lang.noclassdeffounderror: org/eclipse/swt/swt @ chrriis.dj.nativeswing.swtimpl.core.swtnativeinterface.initialize_(swtnativeinterface.java:213) @ chrriis.dj.nativeswing.swtimpl.nativeinterface.initialize(nativeinterface.java:71) @ chrriis.dj.nativeswing.swtimpl.core.swtnativeinterface.open_(swtnativeinterface.java:337) @ chrriis.dj.nativeswing.swtimpl.nativeinterface.open(nativeinterface.java:100) @ derby.derbyprogram.<init>(derbyprogram.java:161) @ derby.derbyprogram.getinstance(derbyprogram.java:130) @ derby.derbyprogram.main(derbyprogram.java:121) caused by: java.lang.classnotfoundexception: org.eclipse.swt.swt @ java.net.urlclassloader$1.run(urlclassloader.java:372) @ java.net.urlclassloader$1.run(urlclassloader.java:361) @ java.security.accesscontroller.doprivileged(native method) @ java.net.urlclassloader.findclass(urlclassloader.java:360) @ java.lang.classloader.loadclass(classloader.java:424) @ sun.misc.launcher$appclassloader.loadclass(launcher.java:308) @ java.lang.classloader.loadclass(classloader.java:357) ... 7 more

addurl seems add together jar list, , not load it. launched programme -verbose argument , didn't loading swt class need. made sure double check library, , indeed class exists , in right directory.

this code:

public static void main(string[] args){ seek { loadswtjar(); } grab (malformedurlexception | illegalaccessexception | illegalargumentexception | invocationtargetexception | nosuchmethodexception | securityexception e) { e.printstacktrace(); } nativeinterface.open();//this throws exception } private void loadswtjar() throws malformedurlexception, illegalaccessexception, illegalargumentexception, invocationtargetexception, nosuchmethodexception, securityexception { string osname = system.getproperty("os.name").tolowercase(); string osarch = system.getproperty("os.arch").tolowercase(); urlclassloader classloader = (urlclassloader) getclass().getclassloader(); method addurlmethod = urlclassloader.class.getdeclaredmethod("addurl", url.class); addurlmethod.setaccessible(true); string swtfilenameospart = osname.contains("win") ? "win" : osname.contains("mac") ? "maco" : osname.contains("linux") || osname.contains("nix") ? "linux" : ""; // throw new runtimeexception("unknown os name: "+osname) string swtfilenamearchpart = osarch.contains("64") ? "64" : "32"; string swtfilename = "swt-" + swtfilenameospart + "-" + swtfilenamearchpart + ".jar"; url swtfileurl = new url("file:" + system.getproperty("user.dir") + "/lib/"+swtfilename); addurlmethod.invoke(classloader, swtfileurl); system.out.println("loaded swt jar: " + swtfileurl);//this outputs right path , file. file contains right stuff in it. }

here swt.class beingness accessed: other libraries dj native swing , swt. ideas?

java swt classloader

Comments

Popular posts from this blog

java Multi query from Mysql using netbeans -

c# - DotNetZip fails with "stream does not support seek operations" -

c++ - StartServiceCtrlDispatcher don't can access 1063 error -