请教为什么Can't find default package `javax.swing'.
redhat8,j2sdk1.4.1_01
我从网上下载了一个源程序如下:
/* Graphics04.java */
import javax.swing.*;
import java.awt.*; // for BorderLayout
class Graphics04 {
public static void main(String[] args) {
SimpleFrame frame = new SimpleFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JPanel pane = new JPanel();
JButton button1 = new JButton("Click Me!");
pane.add(button1);
JButton button2 = new JButton("Click Me Too!");
pane.add(button2);
frame.getContentPane().add(pane);
JLabel label = new JLabel("Hi there!");
frame.getContentPane().add(label,BorderLayout.SOUTH);
frame.show();
}
}
class SimpleFrame extends JFrame {
public SimpleFrame() {
setTitle("Graphics04");
setSize(300, 200);
}
}
javac Graphics04.java
结果有六个错误:
Graphics04.java:3: Can't find default package `javax.swing'. Check the CLASSPATH environment variable and the access to the archives
Graphics04.java:10: Type `JPanel' not found in the declaration of the local variable `pane'.
JPanel pane = new JPanel();
^
Graphics04.java:11: Type `JButton' not found in the declaration of the local variable `button1'.
JButton button1 = new JButton("Click Me!");
^
Graphics04.java:13: Type `JButton' not found in the declaration of the local variable `button2'.
JButton button2 = new JButton("Click Me Too!");
^
Graphics04.java:16: Type `JLabel' not found in the declaration of the local variable `label'.
JLabel label = new JLabel("Hi there!");
^
Graphics04.java:22: Superclass `JFrame' of class `SimpleFrame' not found.
class SimpleFrame extends JFrame {
^
6 errors
请问该怎么办那?
我已经修改了~/bash._profile
JAVA_HOME=/usr/local/j2sdk1.4.1_01
export JAVA_HOME
CLASSPATH=/usr/local/j2sdk1.4.1_01/lib:/usr/local/j2sdk1.4.1_01/jre/lib
export CLASSPATH
PATH=$PATH:/usr/local/j2sdk1.4.1_01/bin:/usr/local/j2sdk1.4.1_01/jre/bin
export PATH
不知道对不对?那个程序在win2000下运行通过
谢谢