I am new to Mac OS X and is using version 10.6.5. JDK 1.6_u22 seems to be preinstalled on the system. I have downloaded Eclipse 3.5.2.
It works fine if I create a simple hello world, but I can not import JFrame or use Swing. The error message that I get is:
Access restriction: The type JFrame is not accessible due to restriction on required library /System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Classes/classes.jar
Here is the simple program that I have tried with:
import javax.swing.JFrame;
public class Test {
public static void main(String[] args) {
new JFrame();
}
}
How do I use Java Swing in Eclipse on Mac OS X?
On Mac OS X 10.5.8, Eclipse 3.4.2 and Xcode 3.1.4, the example below builds and runs using recent revisions of either Java 1.5 or Java 1.6. As Xcode includes the JDK, what version of Mac OS X and Xcode are you using?
Also verify that your Swing project hasn’t inadvertently included SWT.
Addendum: Check these two dialogs:
You should see references to
/System/Library/Frameworks/JavaVM.framework/.