Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use sun.* classes in Eclipse Java project

I was sent some Java code that uses classes in the sun.awt.shell package, which is not part of the JDK public API, so Eclipse will not compile the project:

Access restriction: The method getIcon(boolean) from the type ShellFolder is not accessible due to restriction on required library /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Classes/classes.jar

While I agree with the sentiment, can I coerce Eclipse to compile it anyway?

like image 327
Thilo Avatar asked Jun 23 '26 04:06

Thilo


1 Answers

In Window -> Preferences -> Java -> Compiler -> Errors/Warnings, find the "Deprecated and restricted API section", and change the "Forbidden reference" setting from Error to Warning or Ignore.

like image 121
Ash Avatar answered Jun 24 '26 17:06

Ash