exception in initializer error?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • game2d
    New Member
    • Apr 2013
    • 59

    exception in initializer error?

    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 'ExceptionInIni tializerError' but no details.

    does the error has to do with the code below?

    Code:
    public void run()
    	{
    		while(!player_class.isDEAD()) 		                
                  {
    		    ....	
    			repaint();
    			try
    			{
    				Thread.sleep(10);
    			}
    			catch(InterruptedException e)
    			{
    				e.printStackTrace();
    			}	
    		}/*** end of while loop ***/
    	}/*** end of run method ***/
  • Nepomuk
    Recognized Expert Specialist
    • Aug 2007
    • 3111

    #2
    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.

    Comment

    • game2d
      New Member
      • Apr 2013
      • 59

      #3
      by static do you mean static variable or method?

      bc i have some static variables:

      private static final long serialVersionUI D = 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

      Comment

      • Nepomuk
        Recognized Expert Specialist
        • Aug 2007
        • 3111

        #4
        Those look ok, at least out of context. I am however a little confused by the comment
        Code:
        //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.

        Comment

        • game2d
          New Member
          • Apr 2013
          • 59

          #5
          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
          Code:
          Main.WINDOW_WIDTH
          do you think this is the problem?

          Comment

          • Nepomuk
            Recognized Expert Specialist
            • Aug 2007
            • 3111

            #6
            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 ExceptionInInit ializerError), 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.

            Comment

            Working...