The main class is a special class for only one reason: when starting the Java virtual machine, this function is what calls the JVM. This is essentially just like any other function, and in fact you can call one main class function from another class.
When compiling a project with multiple classes, you tell the JVM to start the class with the main class that you want to use, for example:
java SomeClass
and it will run the SomeClass main method, assuming that SomeClass is compiled and that the corresponding compiled file is in your class path. (This is what you will need to solve with your specific OS, but I believe that for the -cp option it is enough to specify the class path). So:
java -cp /home/MyName Someclass
the main function SomeClass will be launched in the directory / home / MyName
CosmicComputer Jul 18 2018-12-18T00: 00Z
source share