There are some rules about what files your code must go into. The simplest thing is to put each class into its own file. Each such file must be named after the class, with the extension ".java". For example, suppose you had a program with these classes: Grid, Cell, LiveCell, and EmptyCell. Your Grid class would go into a file called Grid.java, LiveCell would go into LiveCell.java, and so on.
To compile the program, use the "javac" command. Give it the name of the class containing the main method that you wish to run. For example, if you want to run the main method in class Life, you would type
javac Life.javaYou must include the ".java" extension. This will automatically cause all classes used by Life.java to also be compiled.
If there are any compile-time errors, you'll get messages about them. Fix the errors and try compiling again.
When you have successfully compiled the program with no errors, you will find that you have a ".class" file for every ".java" file. These contain the bytecode for your classes. You can now run your program, using the "java" command. Give it the name of the class, with no extension. For example,
java Lifewould run the main method inside Life.