How do I run java program with multiple classes from cmd?
cmd, java
Solution
javac *.java // compliles all java files in the dir
java MyClass // runs the particular file
If one class is dependent on another class that hasn't been compiled yet, the program won't run. So you should compile all files before trying to run the program dependent on other files.
If your files are packaged, then something like this
javac com.mypackage/.*java
java com.mypackage.MyClass
Problem
At the moment I am looking for another way to run my Java program from command line, other than adding it to a JAR file. My program has the following number of classes: The name of the program file - MyProgram Main class - Server1 second class - Client Handler Package name - Items 3rd class - User1 4th class - User2 The main class and client handler alongside the package will have to run first in order for user 1 & user 2 to run, because they are client classes and are dependent on the main class.