Why do I get “non-static variable this cannot be referenced from a static context”?

Your nested class (which isn’t a subclass, by the way) isn’t marked as being static, therefore it’s an inner class which requires an instance of the encoding class (JavaApp1) in order to construct it. Options: Make the nested class static Make it not an inner class (i.e. not within JavaApp1 at all) Create an instance … Read more