Java files are source code edited by programmers from where to create executable files. An example about code structure is a sample TicTacToe game:

  1. create java file with main class (ie: TicTacToe class) and assign it the TicTacToe.java name
  2. if application is simple and uses few and simple classes, insert these class auxiliary into TicTacToe class
  3. else create one file for each class and declare each class into TicTacToe class

It is not possible run directly TicTacToe.java file. It needs to compile java file:

javac -g TicTacToe.java

and then it is possible run application recall name of main class:

java TicTacToe

This method is same if there are created one file for each class.

Reference: Wikipedia