How To Execute A Java File
Executing a Java file requires the use of Windows Command Prompt (Windows), Terminal/Shell (Mac & Linux), or an IDE.
The screenshots below are from Windows Command Prompt, but the java commands will look the same whether using Windows, Mac, Linux, or remote terminals such as PuTTY.
Change the working directory to the location in which the .java file you wish to run is contained. For the screenshot below, for example, the working directy was e:\csci wiki\java
Make sure the .java file has been compiled
before moving to the next step.
Type java filenameX
, where filenameX
is the name of the file to be ran without the extension
, and press the Enter
The JAVA file should have executed.