QQ登录

只需一步,快速开始

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 1343|回复: 0

请教为什么Can't find default package `javax.swing'.

[复制链接]
发表于 2002-11-18 10:24:15 | 显示全部楼层 |阅读模式
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下运行通过
谢谢
您需要登录后才可以回帖 登录 | 注册

本版积分规则

GMT+8, 2024-11-16 19:25 , Processed in 0.067157 second(s), 16 queries .

© 2021 Powered by Discuz! X3.5.

快速回复 返回顶部 返回列表