• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?)
 
Ranch Hand
Posts: 3244
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
RH
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


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!
 
Sheriff
Posts: 9109
12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
RH
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic