我有错误,同时运行该代码如下: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