Java报错合集

2019-05-13  本文已影响0人  _理查德

1.  创建 Java 项目后新建 Class,出现报错:The project was not built...

fig-1. The project was not built...

👌 解决方法:单击项目名称,Properties - Java Build Path - Libraries 下点击 JRE System Library, 选择 JRE-1.1

2. 继承 JFrame 时报错:The type 'JFrame' is not API...

fig-2. The type 'JFrame' is not API...

👌 解决方法:修改eclipse的错误级别设置,

Windows -> Preferences -> Java -> Compiler -> Errors/Warnings -> Deprecated and restricted API -> Forbidden reference (access rules): -> 改为 warning

⚠️ 只是将报错改为warning,可能仍存在问题

👌 解决方法:右键点击 JRE System Library... - Build Path - Configure Build Path

选择 JRE System Library[OSGI]... ,选择 remove 进行移除

点选右边的 Add Library,双击第一个 JRE System Library,默认 Finish

上一篇 下一篇

猜你喜欢

热点阅读