코드는 다음과 같습니다.
package mscontroller;
import javax.swing.*;
import com.apple.eawt.Application;
public class Main {
public static void main(String[] args)
{
Application app = new Application();
app.setEnabledAboutMenu(true);
AMEListener listener = new AMEListener();
app.addApplicationListener(listener);
JFrame mainFrame = new JFrame("Application Menu Example");
mainFrame.setSize(500, 500);
mainFrame.setVisible(true);
}
}
여기 오류가 있습니다 :
Exception in thread "main" java.lang.Error: Unresolved compilation
problems: Access restriction: The type 'Application' is not API
(restriction on required library
'/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/rt.jar')
Access restriction: The constructor 'Application()' is not API
(restriction on required library
'/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/rt.jar')
Access restriction: The type 'Application' is not API (restriction on
required library
'/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/rt.jar')
Access restriction: The method
'Application.setEnabledAboutMenu(boolean)' is not API (restriction on
required library
'/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/rt.jar')
AMEListener cannot be resolved to a type AMEListener cannot be
resolved to a type
at mscontroller.Main.main(Main.java:9)
이클립스는 다음과 같이 말합니다.
액세스 제한 : 'Application'유형이 API가 아닙니다 (필수 라이브러리 '/Library/Java/JavaVirtualMachines/jdk1.8.0_11.jdk/Contents/Home/jre/lib/rt.jar'에 대한 제한)