Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Newcomers » Newcomers » import javax.swing.JFrame(Error Message)
import javax.swing.JFrame [message #1385490] Fri, 06 June 2014 22:45 Go to next message
tom young is currently offline tom youngFriend
Messages: 2
Registered: June 2014
Junior Member
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();

}

}
Re: import javax.swing.JFrame [message #1385502 is a reply to message #1385490] Sat, 07 June 2014 15:46 Go to previous messageGo to next message
Russell Bateman is currently offline Russell BatemanFriend
Messages: 3798
Registered: July 2009
Location: Provo, Utah, USA
Senior Member

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.
Re: import javax.swing.JFrame [message #1385504 is a reply to message #1385502] Sat, 07 June 2014 18:44 Go to previous messageGo to next message
Nhi Vanye is currently offline Nhi VanyeFriend
Messages: 6
Registered: June 2014
Junior Member
I agree it sounds like a Windows permissions issue, but an odd one. Are you sharing the computer with someone else? You don't even have read access to the library. Navigate as far as you can from C:\ towards rt.jar and pay attention to any messages that pop up, such as "You must have Administrator authority." Also, right click on each folder along the way (and on rt.jar if you get that far). Select "Properties" and click the Security tab on the pop-up. Then select "users" to see what permissions you have for that item as a user. At the bottom of that display, there should be a link "Learn about permissions." You may learn enough to fix it yourself, or you may need some hands-on assistance. If you share the computer with someone else, perhaps they can help. Or you may be able to get help at the store where you bought the computer.

Good luck!


Vanye
Re: import javax.swing.JFrame [message #1385516 is a reply to message #1385504] Sun, 08 June 2014 13:04 Go to previous messageGo to next message
David Wegener is currently offline David WegenerFriend
Messages: 1441
Registered: July 2009
Senior Member
This isn't a permissions problem on the rt.jar file. You have likely selected an execution environment that doesn't support Swing. Right click your project and select Properties. In the Properties dialog select Java Build Path. Go to the Libraries tab and select the JRE System Library entry. This lists the JRE/JDK you are compiling against. It also specifies the execution environment that you will run against. You want it to read something like: JRE System Library[JavaSE-1.7]. My guess is your's shows something like JRE System Library[CDC-1.1/Foundation-1.1] or something similar. This tells the Eclipse compiler to assume that you application will run in an embeded device that only supports a subset of the full JDK.

You can change the setting by clicking the Edit button. From the Execution Environment drop down select a full Java SE environment (eg JavaSE-1.7 for a 1.7 environment).
Re: import javax.swing.JFrame [message #1385521 is a reply to message #1385502] Sun, 08 June 2014 15:22 Go to previous message
tom young is currently offline tom youngFriend
Messages: 2
Registered: June 2014
Junior Member
Thanks to all of you who replied to my request. I finally figured out what the problem was.

The solution to anyone who runs across the problem is that when I installed Eclipse it did not automatically include the JRE System Library [jre8]. Once I went to ADD Library
and clicked on JRE System Library [jre8]everything worked great.

I'm not sure why it was not included by default upon installation but some times the hunt and peck procedure does work.

Previous Topic:eclipse(or ADT) versions/setting generating different template code
Next Topic:Eclipse 4.3.2 closes the first access in ubuntu 14:04
Goto Forum:
  


Current Time: Sat Oct 24 17:49:25 GMT 2020

Powered by FUDForum. Page generated in 0.03004 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top