Access restriction: The type JFrame is not accessible due to restriction on required library




eclipse开发工具

1)无法解析继承的类名:

*********************************************
package com.hao123;
import javax.swing.*;

public class HisJFrame extends javax.swing.JFrame
{

 /**
  * @param args
  */
 public static void main(String[] args)
 {
 // TODO Auto-generated method stub
    JFrame f=new JFrame();
    f.setSize(100,200);
 }
}

********************************************************
error:
Access restriction: The type JFrame is not accessible due to restriction on required library D:\java2sdk\jre\lib\rt.jar

 at com.hao123.HisJFrame.main(HisJFrame.java:13)
Exception in thread "main"

解决方法:
Project -> Properties -> libraries,
先remove掉JRE System Library,然后再Add Library重新加入D:\java2sdk\jre\lib【我安装java目录】下面的 .jar 包。

你可能感兴趣的:(java)