Running Programs
After you have compiled your source files into bytecode using the javac command, you are ready to execute them. To do so, you need to follow these directions.
Navigate to the directory that stores your top-level package. For the examples in this book, that is a directory called C:\garage\classes. If you are using an IDE, your classes directory might be different. For example, an Eclipse project might store files at C:\eclipse\workspace\garage\classes. In any case, it is the directory that contains your packages, and where you specify the compiler to output code.
Run the java command, passing it the fully qualified name of your class (including all of the package names).
Make sure to use the . separator for packages—not your system ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access