Java NoClassDefFound Error main method


After a bit of grief and struggling, I found out that the main method of a java class must be in the default or root package in order for java to find it and execute it. If the ‘public static void main(String[] args)’ method is in a class that is in a different package than the root one, it will not be found and you will get a NoClassDefFound error.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s