您好,登錄后才能下訂單哦!
怎么解決java的class文件運(yùn)行時(shí)提示找不到或無(wú)法加載主類?針對(duì)這個(gè)問(wèn)題,今天小編總結(jié)了這篇文章,希望能幫助更多想解決這個(gè)問(wèn)題的朋友找到更加簡(jiǎn)單易行的辦法。
問(wèn)題如下
TestOne.java
package moon.star; public class TestOne { public void fTestOne() { System.out.println("I an a method In TestOne class"); } }
TestTwo.java
package moon.star; public class TestTwo { public void fTestTwo() { System.out.println("I an a method In TestTwo class"); } }
運(yùn)行的代碼:
import moon.star.*; public class Use { public static void main(String args[]) { TestOne a = new TestOne(); a.fTestOne(); TestTwo b = new TestTwo(); b.fTestTwo(); } }
輸入 javac Use.java編譯沒(méi)有問(wèn)題,輸入java Use運(yùn)行時(shí)卻出錯(cuò)!
問(wèn)題解決
命令行輸入set classpath=C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\Jerry.jar;.;E:\1000
來(lái)指明我的moon.star包的位置,位置是E:\1000,即包名為moon.star的類的字節(jié)碼存放在E:\1000\moon\star目錄中。用戶可以更新classpath的設(shè)置。
C:\Users\前世藥師\Desktop>set classpath=C:\Program Files\Java\jdk1.8.0_201\jre\lib\ext\Jerry.jar;.;E:\1000
關(guān)于解決java的class文件運(yùn)行時(shí)提示找不到或無(wú)法加載主類的方法就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺(jué)得文章不錯(cuò),可以把它分享出去讓更多的人看到。
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。