Questions tagged [executable-jar]

A special type of jar file which contains all non-standard libraries and definitions necessary to run an application on a JVM.

An executable java program which can be started manually by typing java -jar foo.jar. Some operating systems (including Windows, Solaris and some Linux distributions) provide means to run the jar just as any other executable on that system.

Executable JAR files are distinguished by a 'extra field' on the first file with a hexadecimal field code of 0xCAFE. They must also specify a main class in the manifest (Main-Class: fooPackage.BarClass) which will be used to start the application.

2238 questions
2598
votes
31 answers

How can I create an executable JAR with dependencies using Maven?

I want to package my project in a single executable JAR for distribution. How can I make a Maven project package all dependency JARs into my output JAR?
soemirno
  • 26,526
  • 3
  • 17
  • 14
602
votes
32 answers

How to get the path of a running JAR file?

My code runs inside a JAR file, say foo.jar, and I need to know, in the code, in which folder the running foo.jar is. So, if foo.jar is in C:\FOO\, I want to get that path no matter what my current working directory is.
Thiago Chaves
  • 8,439
  • 5
  • 25
  • 25
475
votes
22 answers

"Invalid signature file" when attempting to run a .jar

My java program is packaged in a jar file and makes use of an external jar library, bouncy castle. My code compiles fine, but running the jar leads to the following error: Exception in thread "main" java.lang.SecurityException: Invalid signature…
user123003
257
votes
26 answers

Running JAR file on Windows

I have a JAR file named helloworld.jar. In order to run it, I'm executing the following command in a command-line window: java -jar helloworld.jar This works fine, but how do I execute it with double-click instead? Do I need to install any…
DonX
  • 15,033
  • 20
  • 71
  • 119
194
votes
10 answers

How do I tell Spring Boot which main class to use for the executable jar?

Execution default of goal org.springframework.boot:spring-boot-maven-plugin:1.0.1.RELEASE:repackage failed: Unable to find a single main class from the following candidates My project has more than one class with a main method. How do I tell the…
Thilo
  • 241,635
  • 91
  • 474
  • 626
188
votes
6 answers

How to run a class from Jar which is not the Main-Class in its Manifest file

I have a JAR with 4 classes, each one has Main method. I want to be able to run each one of those as per the need. I am trying to run it from command-line on Linux box. E.g. The name of my JAR is MyJar.jar It has directory structure for the main…
Bhushan
  • 16,055
  • 24
  • 96
  • 132
151
votes
37 answers

What causes "Unable to access jarfile" error?

I want to execute my program without using an IDE. I've created a jar file and an exectuable jar file. When I double click the exe jar file, nothing happens, and when I try to use the command in cmd it gives me this: Error: Unable to access…
Joseph Smith
  • 2,595
  • 5
  • 17
  • 18
125
votes
4 answers

Building executable jar with maven?

I am trying to generate an executable jar for a small home project called "logmanager" using maven, just like this: How can I create an executable JAR with dependencies using Maven? I added the snippet shown there to the pom.xml, and ran mvn…
RMorrisey
  • 7,239
  • 8
  • 49
  • 66
122
votes
7 answers

Execute another jar in a Java program

I had written several simple java applications named as A.jar, B.jar. Now i want to write a GUI java program so that user can press button A to execute A.jar and button B to execute B.jar. Also i want to output the run-time process detail in my GUI…
winsontan520
  • 2,074
  • 5
  • 19
  • 18
111
votes
4 answers

Run java jar file on a server as background process

I need to run a java jar in server in order to communicate between two applications. I have written two shell scripts to run it, but once I start up that script I can't shut down / terminate the process. If I press ctrl+C or close the console, the…
Bernad Ali
  • 1,519
  • 5
  • 22
  • 29
94
votes
14 answers

how to check the version of jar file?

I am currently working on a J2ME polish application, just enhancing it. I am finding difficulties to get the exact version of the jar file. Is there any way to find the version of the jar file for the imports done in the class? I mean if you have…
Ritesh Mengji
  • 5,356
  • 8
  • 28
  • 46
86
votes
5 answers

How to make an executable JAR file?

I have a program which consists of two simple Java Swing files. How do I make an executable JAR file for my program?
Reuben
  • 5,198
  • 9
  • 40
  • 52
82
votes
5 answers

Building a runnable jar with Maven 2

I'm relatively new to the Maven mantra, but I'm trying to build a command-line runnable jar with Maven. I've setup my dependencies, but when I run mvn install and attempt to run the jar, two things happen. First, no main class is found, which is…
Stefan Kendall
  • 61,898
  • 63
  • 233
  • 391
66
votes
6 answers

Java Jar file: use resource errors: URI is not hierarchical

I have deployed my app to jar file. When I need to copy data from one file of resource to outside of jar file, I do this code: URL resourceUrl = getClass().getResource("/resource/data.sav"); File src = new File(resourceUrl.toURI()); //ERROR…
hqt
  • 27,058
  • 46
  • 161
  • 235
64
votes
5 answers

How do I create an executable fat jar with Gradle with implementation dependencies

I've got a simple project in Gradle 4.6 and would like to make an executable jar of it. I've tried shadow, gradle-fatjar-plugin, gradle-one-jar, spring-boot-gradle-plugin plugins but neither of them adds my dependencies declared as implementation (I…
Dmitry Senkovich
  • 4,543
  • 5
  • 27
  • 58
1
2 3
99 100