How to run a Java program

Quickly run .jar files in Windows and Linux

Prerequisites: N/A

Difficulty Level: Member • Nerd • Platypus

Estimated Time: 3 minutes

Expected Outcome: The .jar file will execute

Tools Required: A Windows or Linux computer with Java installed and a .jar executable file Screen Shot 2020-03-27 at 5.00.45 PM-1

Steps to Perform 

  1. Open a command prompt for Windows or a terminal session for Linux
    1. For Windows users press Windows key+R type "cmd" and press enter
    2. For Linux users press Ctrl+Alt+T
  2. Navigate to the directory the contains the .jar file
    1. An easy way to do this is to drag and drop the .jar file into the command prompt window
    2. You can also use the cd command and manually type out the directory that contains your .jar file. For example:
      cd C:\Users\user\Desktop
  3. Once you are in the same directory as the .jar file run the following command
    java -jar "YOUR FILE NAME.jar"
    This should execute your .jar file