我有錯誤,同時運行該代碼如下:Java類路徑問題
import java.awt.*;
import javax.swing.*;
import org.fife.ui.rtextarea.*;
import org.fife.ui.rsyntaxtextarea.*;
public class TextEditorDemo extends JFrame {
private static final long serialVersionUID = 1L;
public TextEditorDemo() {
JPanel cp = new JPanel(new BorderLayout());
RSyntaxTextArea textArea = new RSyntaxTextArea();
textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA);
RTextScrollPane sp = new RTextScrollPane(textArea);
cp.add(sp);
setContentPane(cp);
setTitle("RSyntaxTextArea 1.4 - Example 1 - Text Editor Demo");
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
}
public static void main(String[] args) {
// Start all Swing applications on the EDT.
SwingUtilities.invokeLater(new Runnable() {
public void run() {
new TextEditorDemo().setVisible(true);
}
});
}
}
當我運行使用java -classpath rsyntaxtextarea.jar;. TextEditorDemo
,我沒有收到輸出。 我得到錯誤,而不是:
Exception in thread "main" java.lang.NoClassDefFoundError: TextEditorDemo
Caused by: java.lang.ClassNotFoundException: TextEditorDemo
at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:248)
Could not find the main class: TextEditorDemo. Program will exit.
任何人都可以幫忙!這個例子是從,RSyntaxTextArea
你得到什麼? – 2011-04-20 13:13:46
什麼錯誤做,如果你沒有任何-classpath選項運行它,你得到什麼? – 2011-04-20 14:33:11