How to run a jar file in Eclipse

You cannot directly execute a jar file. Instead, you need to run it using the java -jar command. In order to do that you:

  1. Go to Run > External Tools > External tools Configurations
  2. Create an item under "Program"
  3. Fill in:

    Location: /usr/bin/java (or the route to your java executable, in Linux you can find this by running which java on a terminal, in Windows you can use where java in command prompt)

    Working directory: The working directory for your jar program (usually its location)

    Arguments: -jar [path to your jar]


You could run the JAR with an "External Tool" launch configuration, found at Run > External Tools > External tools Configurations.


Run -> External Tools -> External Tools Configuration.

Program -> New

enter image description here

Tags:

Java

Eclipse