Hey guys,

I've constructed the main class to refer to a variable in it and I receive a stack overflow error. Any suggestions on the causes of this error, I've used this method previously and have not got this before.

In other class:

MainClass class = new MainClass();


Exception in thread "main" java.lang.StackOverflowError
	at java.awt.Insets.<init>(Insets.java:86)
	at sun.awt.windows.WToolkit.getScreenInsets(Native Method)
	at sun.awt.windows.WToolkit.getScreenInsets(WToolkit.java:549)
	at java.awt.Window.init(Window.java:395)
	at java.awt.Window.<init>(Window.java:433)
	at jav

       . . . and so on


somewhere in the ... and so on it gives details of the lines in your program that it was executing when it overflowed. This is essential info. Anyway, it looks like it's in the middle of creating a window, so your loop is probably in the creation of the new frame, and is probably recursive. Can you post the code?

This article has been dead for over six months. Start a new discussion instead.