In this guide, I will be showing you how you can run .java files from the command line/terminal on a Mac in OS X.
In order to follow this tutorial, you will need the following
Compiling and Running a .java file on OS X
The first thing you will need to do is to open the Terminal. You can do this by following the images below.
Once you have opened terminal, you will need to navigate to the directory you have stored your .java file. You can use this by using the cd command showing in the screenshot below. You can then view everything in that directory by typing the ls command.
The final thing is to compile and run our program. The command for this is as follows
to run the program, we type in
You can see a full example in the image below.