• Post Reply Bookmark Topic Watch Topic
  • New Topic

java.lang.IllegalAccessError  RSS feed

 
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I get an error when running this:



This give me an java.lang.IllegalAccessError, how can i solve this i have too use inner clases ???

Frank
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The description of IllegalAccessError in the API documentation says:

Thrown if an application attempts to access or modify a field, or to call a method that it does not have access to.

Normally, this error is caught by the compiler; this error can only occur at run time if the definition of a class has incompatibly changed.


That means you normally only get this error at runtime when your .class files are not compiled correctly; you may be combining old and new versions of .class files, or maybe you're running your code on a different Java version that has an incompatibility with the version you compiled it on.

By the way, there's another potential bug in your code.

Do you understand that this sets the date of the calendar to 23 February 2005 (not January)? Months are 0-based, as the API documentation says; so 0 = January, 1 = February, etc.

Also, if you start an integer literal in Java with a 0 (as you did with "01" in the statement above) it is interpreted as an octal (not decimal) number.

You probably meant this:
 
Frank Jacobsen
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont understand this, all the classes are compiled ok in the websphere computer, and yes the date is correct, it schuld be 23 february 2005....

But i havent any ide, why i dident hava access too the fields, they are public, and the methoeds are public, its innerclasses, but that schould not do any difrens !

Frank
 
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What version of Java are you using? Since 1.4, Calendar's getTimeInMillis is public but in 1.3 (and before, I believe) the method was protected. If you are using 1.3, you could write:The intermediate object there is a java.util.Date.
 
Frank Jacobsen
Ranch Hand
Posts: 358
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I will try this tomorow, im using java 1.3 soooo, if this is right im a happy man

Thanks
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also note that since this got past your compiler and was a runtime error, if it is the 1.3/1.4+ difference in Calendar's getTimeInMillis, it means that your compiler and your jre are from different versions, which is best avoided in any case. So you should check!
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!