我在同一個(gè)文件夾中編寫(xiě)了幾個(gè)類,這是層次結(jié)構(gòu):bookpirate/-Window.java-Navigator.java-NavEventHandler.java所有文件都有“package bookpirate;” 在一開(kāi)始的時(shí)候這是我導(dǎo)入它們的方法:導(dǎo)航器類:package bookpirate;import javax.swing.*;import java.awt.*;import bookpirate.NavEventHandler;public class Navigator{ private JPanel panel; public JTextField page; public JButton pageBack; public JButton addBefore; public JButton addAfter; public JButton pageForward; public JButton removePage; public JButton undo; public JTextField getPage() { return page; } public JButton getPageBack() { return pageBack; } public JButton getAddBefore() { return addBefore; } public JButton getAddAfter() { return addAfter; } public JButton getPageForward() { return pageForward; } public JButton getRemovePage() { return removePage; } public JButton getUndo() { return undo; } public int nOfPages; public int getNOfPages() { return nOfPages; } public static void main(String[] args) { new Navigator(); } public Navigator() { setListeners(); System.out.println("Created NavEventHandler"); }這是我編譯 NavEnventHandler 時(shí)得到的結(jié)果:C:\Users\...\bookpirate>javac NavEventHandler.javaNavEventHandler.java:5: error: cannot find symbolimport bookpirate.Navigator; ^ symbol: class Navigator location: package bookpirateNavEventHandler.java:9: error: cannot find symbol Navigator navigator; ^一直以來(lái)我都可以毫無(wú)錯(cuò)誤地將它們編譯在一起C:\Users\Falangrater\Desktop\Files\Programming\bookpirate>javac NavEventHandler.java Navigator.java Window.javaC:\Users\Falangrater\Desktop\Files\Programming\bookpirate>但我無(wú)法一起或單獨(dú)運(yùn)行它們C:\Users\Falangrater\Desktop\Files\Programming\bookpirate>java Window Navigator NavEventHandlerError: Could not find or load main class WindowC:\Users\Falangrater\Desktop\Files\Programming\bookpirate>我嘗試過(guò)制作一個(gè)manifest.txt文件Main-Class: Window我無(wú)法將 .mf 添加到文件中我試圖盡可能簡(jiǎn)潔
2 回答

天涯盡頭無(wú)女友
TA貢獻(xiàn)1831條經(jīng)驗(yàn) 獲得超9個(gè)贊
您不必從同一個(gè)包中導(dǎo)入類。?
您的任何類中都沒(méi)有 main 方法,因此您無(wú)法以這種方式運(yùn)行它。
編輯:您只需移動(dòng)到父目錄并這樣調(diào)用它:
java bookpirate.Navigator
或者java bookpirate/Navigator

瀟湘沐
TA貢獻(xiàn)1816條經(jīng)驗(yàn) 獲得超6個(gè)贊
這就是問(wèn)題所在:
我將這些課程放在 bookpirate 包中。因此,我需要位于 bookpirate 的父文件夾中才能運(yùn)行該程序:
/Programming> java bookpirate/Window
或者
/Programming> java bookpirate.Window
代替:
/bookpirate> java Window
添加回答
舉報(bào)
0/150
提交
取消