By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,805 Members | 1,280 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,805 IT Pros & Developers. It's quick & easy.

exception in initializer error?

P: 59
I created a japplet in java and put it on website. there are no errors in eclipse and it works fine.

on web it say "Error - click for details". when i click on it, it says 'ExceptionInInitializerError' but no details.

does the error has to do with the code below?

Expand|Select|Wrap|Line Numbers
  1. public void run()
  2.     {
  3.         while(!player_class.isDEAD())                         
  4.               {
  5.             ....    
  6.             repaint();
  7.             try
  8.             {
  9.                 Thread.sleep(10);
  10.             }
  11.             catch(InterruptedException e)
  12.             {
  13.                 e.printStackTrace();
  14.             }    
  15.         }/*** end of while loop ***/
  16.     }/*** end of run method ***/
  17.  
Apr 30 '13 #1
Share this Question
Share on Google+
5 Replies


Nepomuk
Expert 2.5K+
P: 3,112
According to the java api docs, this Error is thrown when there's a problem in a static initializer. So, while the above code may CALL something static, there's no way for us to know without more context.

I would suggest checking everything static for errors. Everything else depends on code you haven't posted.
Apr 30 '13 #2

P: 59
by static do you mean static variable or method?

bc i have some static variables:

private static final long serialVersionUID = 1L; //in main
public static final int WINDOW_WIDTH = 900; //in main
public static final int WINDOW_HEIGHT = 400; //in main
public static final int DELAY = 15; //in main
Apr 30 '13 #3

Nepomuk
Expert 2.5K+
P: 3,112
Those look ok, at least out of context. I am however a little confused by the comment
Expand|Select|Wrap|Line Numbers
  1. //in main
after every line. Are they in a main method? If so, that main method won't be called when running the code as an applet (unless you call it manually). So everything in that method needed for the applet to run would have to be moved elsewhere (e.g. into the run method).

Also, please use [code] tags for posting code.
Apr 30 '13 #4

P: 59
no not main method. i ment main class. i have thoese 4 static variables are in top of main class. and i am using these static variables in different classes by
Expand|Select|Wrap|Line Numbers
  1. Main.WINDOW_WIDTH
  2.  
do you think this is the problem?
Apr 30 '13 #5

Nepomuk
Expert 2.5K+
P: 3,112
Hm, it shouldn't be... Is there anything else that's static? And when you click on click for details (you know, where you got the ExceptionInInitializerError), is there anything clickable there? There should be a stacktrace or something. Alternatively, the server you're running should have a log file in which you can check the details. Somewhere there it should tell you what line of code caused this error.
May 2 '13 #6

Post your reply

Sign in to post your reply or Sign up for a free account.