[英]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.