How to run jar file in Eclipse

I tried to run the jar file by selecting “Run configurations” and then creating a new Java application, but Eclipse wants me to give it the main class and the project link. Can't I just give the eclipse jar file?

+17
source share
4 answers

You can launch the JAR with the launch tool configuration "External tool" located in the "Run"> "External tools"> "External tool configurations" section.

+8
source

You cannot directly execute the jar file. Instead, you need to run it using the java -jar . To do this, you:

  • Go to Run> External Tools> External Tools. Configurations
  • Create an item in the "Program" section
  • Fill in:

    Location: /usr/bin/java (or the route to the java executable, on Linux you can find it by running which java on the terminal, on Windows you can use where java on the command line)

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

    Arguments: -jar [path to your jar]

+45
source

Is the jar file you provided open? public static void main (String [] arg)? In order for java to launch yours and the application, there must be a main class with "public static void main (String [] arg)". So jvm will understand the starting point of your jar.

+1
source

Try the following command line

 C:\Program Files (x86)\Java\jdk1.6.0_24\bin\javaw.exe 

with the following arguments (one per line)

 -cp C:\dev\tcpmon-1.0-bin\build\tcpmon-1.0.jar org.apache.ws.commons.tcpmon.TCPMon 
+1
source

Source: https://habr.com/ru/post/1415325/


All Articles