The class containing the main()
function must be public, and you may only define one public class per file. You'll want to have two separate files Risk.java
and Territory.java
.
Risk.java:
public class Risk {
}
Territory.java:
public class Territory
{
public static void main (String[]arg)
{
System.out.println ("hi") ;
}
}
EDIT: It turns out this isn't true - I was able to run your initial code with the following command line:
java territory
But my earlier comments point to the best practice for a real app, such as a Risk game.