简体   繁体   中英

unable to load java class from jar file file

My jar is in Class Path and i want to load a class from jar file i am trying to load it like blow,

Class cls = ClassLoader.getSystemClassLoader().loadClass(<package-name>.<class-name>);

but I am getting

java.lang.ClassNotFoundException: com.perennial.genericsync.xero.SyncAdaptor
    at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
    at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
    at java.security.AccessController.doPrivileged(Native Method)

please help me how can i load class file from jar. jar is already there in Class Path. is it say that System Loader can not load class from jar?

how can I load java class? thanks in advance

如果你的jar在classpath中,请尝试Thread.currentThread().getContextClassLoader().loadClass(name)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM