I just compiled this code and it worked perfectly fine, It may be a issue when you are exporting it make sure you are exporting the file as a runnable JAR file, if you don’t it wont export the necessary documentation defining where the main class is. in Eclipse you can do this by going to the file menu in the top left corner then click export which will bring up the dialogue bellow, then click runnable JAR.
9
solved Error: java.lang.NoClassDefFoundError