JAVA- JFrame- non static method cannot be referenced from a static context [duplicate]

Don’t put your code in the main method. Instead I’d put it into the class constructor for the class the holds the main method, in your case Kalkulator. Then instantiate Kalkulator in the main method. Kalkulator won’t be static, so you won’t recieve this message. If you want to know why you’re getting this error, its because the main method is declared as static, and as the error suggests a static thing can’t access something not static. Check this out.

Leave a Comment