The class containing the main() function must be public, and you can define only one public class for each file. You 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 that this is not true - I was able to run your source code using the following command line:
java territory
But my previous comments point to best practice for a real application, for example, for the game Risk.
source share