![](/img/trans.png)
[英]java.lang.ClassNotFoundException when trying to load applet from a .jar file
[英]ClassNotFoundException when trying to load classes from JAR
我的代码中有以下结构:
在 bin 文件夹中,我有两个包:carFactory 和 bikeFactory。 我为每个工厂目录创建了一个 jar。 然后,我将 jar 都移到了我项目根目录的插件目录中。
在我的代码中,当我尝试使用以下命令加载 class 时:
IAbstractFactory factory = (IAbstractFactory) Class.forName("carFactory.CarFactory", true, ulc)
.getDeclaredConstructor().newInstance();
我收到错误 java.lang.ClassNotFoundException。
更新:
代码写在 Eclipse 但我试图在 CMD 上执行。
类路径的内容:
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-14">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="lib" path="A:/Libs/RSyntaxTextArea/rsyntaxtextarea-3.1.2.jar"/>
<classpathentry kind="output" path="bin"/>
</classpath>
R 先生是对的。 Ty寻求帮助:)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.