Why it could not find the main class?

Roman picture Roman · Mar 10, 2010 · Viewed 7.7k times · Source

I have a very simple code:

package mygame;
public class RunGame {
    public static void main(String[] args) {
        System.out.println(args[0]);
    }
}

I can compile that code but I cannot run it. When I type "java RunGame" in the command line I get:

Exception in thread "main" java.lang.NoClassDefFoundError: RunGame (wrong name: mygame/RunGame).
....
Could not find the main class: RunGame. Program will exit.

Answer

Kannan Ekanath picture Kannan Ekanath · Mar 10, 2010
java mygame.RunGame 

is the java executable syntax. i.e, java classname.qualified.with.full.packaging

Also what is the RunColoredTrails class in the output you have shown?