溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

怎么解決java的class文件運(yùn)行時(shí)提示找不到或無(wú)法加載主類

發(fā)布時(shí)間:2020-06-24 09:28:15 來(lái)源:億速云 閱讀:431 作者:Leah 欄目:編程語(yǔ)言

怎么解決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ò)!

怎么解決java的class文件運(yùn)行時(shí)提示找不到或無(wú)法加載主類

問(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ò),可以把它分享出去讓更多的人看到。

向AI問(wèn)一下細(xì)節(jié)

免責(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)容。

AI