|
Re: import javax.swing.JFrame [message #1385502 is a reply to message #1385490] |
Sat, 07 June 2014 15:46 |
|
On 06/07/2014 01:06 AM, tom young wrote:
> I'm new to java and trying to keep the mind active at age 68. The last
> programming I did was in fortran years ago, and for you youngsters I'm
> sure someone will explain to you what for fortran is.
>
> I keep getting an error message when trying to do this import
> javax.swing.JFrame and I get the following message. I've just got
> started on the program but no use going on
> if I can't get to first base.
>
> Description Resource Path Location Type
> Access restriction: The type JFrame is not accessible due to restriction
> on required library C:\Program Files\Java\jre8\lib\rt.jar
>
>
> package INTERMEDIATE;
>
> import javax.swing.JFrame ;
>
>
> public class GRAPHICS {
> public static void main (String[] args){
> JFrame window = new Jframe();
>
> }
> }
>
Tom,
There might be a permissions problem and, anyway, you'll want to use a
proper JDK. You're using the JRE installed on your Windows 8 system. In
your place, I would download a private copy of the Java Developers Kit
(JDK) from java.sun.com, Downloads, Popular Downloads, Developer
Downloads and unzip it on a local path like C:\Users\tom\jdk1.8.0_5 and
change eclipse.ini accordingly. This way, no matter what JRE the rest of
your host uses, and it will be updated from time to time, the JDK you're
relying on for development will never change unless and until you decide
to do it.
That might sort your problem out (though, as I'm not a Windows guy, I
don't specifically know why the Java runtime library, rt.jar, is
problematic for Eclipse in this instance.)
Second, welcome to the Java Community. There are industry practices
you'll learn about as you go. To illustrate, I'll simply reformat your
code slightly and you'll know what to start looking for:
package com.tomyoung.swingsample.intermediate;
import javax.swing.JFrame;
public class Graphics {
public static void main (String[] args) {
JFrame window = new JFrame();
...
}
}
where tomyoung.com is made up, but should be your own domain, if you own
one, but at very least something that would not coincide with someone
else's package path. You could just use "intermediate" though, but
lowercase.
Please note capitalization--that's the most important thing I'm pointing
out.
Cheers from another old guy who started out life 40 years ago in Fortran
IV, though I wound my way through PL/1, Pascal, ALGOL, Modula-2, Ada, C
and now Java.
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.08690 seconds