aspose file tools*
The moose likes Beginning Java and the fly likes can't access a member of class ... with modifiers Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "can Watch "can New topic
Author

can't access a member of class ... with modifiers ""

RH
Greenhorn

Joined: Jul 08, 2002
Posts: 3
Hello folks!
Cool site! (I might not have the eyes to see all is there to be seen, cause you know, stress reduces the FOV ant all that...)
Howdy from a newbye!
Newbye being, I have troubles. They look like this:

Exception: java.lang.IllegalAccessException: Class sun.applet.AppletPanel can not access a member of class Hello with modifiers ""

this class is supposed to say Hello, and the listing is:


I have BlueJ as IDE and JDK 1.4.01 from www.sun.com, if this helps, and I have loaded my class in a web browser (IE 5.0.2929.6307), where I get this error. The compiler shows that class compiled without errors.
Anyone could help?!...
RH

(why that one eye moose keeps watching me? Did I do something wrong?)


My name was RH Positive. I am always positive. About anything. Now my name is RH.
Dave Vick
Ranch Hand

Joined: May 10, 2001
Posts: 3244
RH Positive
First off:
Welcome to the Java Ranch, we hope you�ll enjoy visiting as a regular however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.
Thanks again and we hope to see you around the ranch!!
Now, for your problem:
It looks like you've defined your Hello class without any access specification so it'll get the default access level, which us package. Meaning that only classes in the same package can access it. Change the class declaration to 'public class Hello' and you should be in business.
Hope that helps


Dave
RH
Greenhorn

Joined: Jul 08, 2002
Posts: 3

First off:
Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular

thanx
however,
your name is not in keeping with our naming policy here at the ranch. Please change your display name to an appropriate name as shown in the policy.

I know, but my name was taken, I have (like nowhere else) 1 login name, another display name, and my name. These make 3 of my names, all different names. I promise to read the policy (there was no time - I was anxious to see my first java working) and to correct that (btw - are guns allowed here? )

It looks like you've defined your Hello class without any access specification so it'll get the default access level, which us package.

Is this a typing error? -> [which us package.] coz I don't get it.

Meaning that only classes in the same package can access it. Change the class declaration to 'public class Hello' and you should be in business.

I'll do that, thank you.
RobertH (+ comes from the fact I was (most of the time) better than the others (in burning IC's and other electronics). It's my better name!
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9047
    
  10
I have loaded my class in a web browser

Why are you trying to run an application in a web browser rather than from the command line? An Applet is a different animal than an Application. An applet extends java.applet.Applet. Your application does not. An applet doesn't need a main() method like your application has.

Try opening a "dos window" and type "java Hello" for a better chance to see results.

Regarding "the default access level, which us package", he meant "the default access level, which is package access." (I don't think that will help you, but changing it to public won't hurt anything either.)

Regarding your name, "RH" is an acceptable first name. Pick a different last name, or use your real last name. Also, I think you should be able to register with and use "Robert H" as your first name if you wish. I login with "Marilyn deQueiroz" and my display name is "Marilyn de Queiroz".

Let us know about your progress with this question.
[ July 08, 2002: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
RH
Greenhorn

Joined: Jul 08, 2002
Posts: 3
Originally posted by Marilyn deQueiroz:
I have loaded my class in a web browser

Why are you trying to run an application in a web browser rather than from the command line?

It's place is in a web browser. It should appear in a web page.
An Applet is a different animal than an Application. An applet extends java.applet.Applet. Your application does not. An applet doesn't need a main() method like your application has.

Will you be kind, sheriff, to explain this to me? It should be an Application to run in a web browser? what's the good of an Applet, then?

Try opening a "dos window" and type "java Hello" for a better chance to see results.

Did that. Look what I got:
Exception in thread "main" java.lang.NoClassDefFoundError: hello (wrong name: Hello)
at java.lang.ClassLoader.defineClass0(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:509)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:123)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:246)
at java.net.URLClassLoader.access$100(URLClassLoader.java:54)
at java.net.URLClassLoader$1.run(URLClassLoader.java:193)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:186)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:265)
at java.lang.ClassLoader.loadClass(ClassLoader.java:262)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:322)
What you say? The error output is longer than my listing. I have to be bad, bad, bad...

Regarding "the default access level, which us package", he meant "the default access level, which is package access." (I don't think that will help you, but changing it to public won't hurt anything either.)

Regarding your name, "RH" is an acceptable first name. Pick a different last name, or use your real last name. Also, I think you should be able to register with and use "Robert H" as your first name if you wish. I login with "Marilyn deQueiroz" and my display name is "Marilyn de Queiroz".

was taken! By the way, nice name!


Regards
Robert H
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: can't access a member of class ... with modifiers ""