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.

2420 questions
2870
votes
33 answers

How can I create an executable/runnable 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
  • 29,244
  • 3
  • 19
  • 14
640
votes
33 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
  • 9,218
  • 5
  • 28
  • 25
504
votes
24 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
296
votes
25 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
  • 16,093
  • 21
  • 75
  • 120
229
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
  • 18,329
  • 31
  • 104
  • 137
209
votes
11 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
  • 257,207
  • 101
  • 511
  • 656
197
votes
40 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
  • 3,243
  • 5
  • 20
  • 18
192
votes
12 answers

Creating runnable JAR with Gradle

Until now I created runnable JAR files via the Eclipse "Export..." functionallity but now I switched to IntelliJ IDEA and Gradle for build automation. Some articles here suggest the "application" plugin, but this does not entirely lead to the result…
Hannes
  • 5,002
  • 8
  • 31
  • 60
165
votes
19 answers

Using Gradle to build a JAR with dependencies

I have a multiproject build and I put a task to build a fat JAR in one of the subprojects. I created the task similar to the one described in this cookbook. jar { from configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } …
Ben McCann
  • 18,548
  • 25
  • 83
  • 101
138
votes
8 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,284
  • 5
  • 21
  • 18
130
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,637
  • 9
  • 53
  • 71
127
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,699
  • 6
  • 23
  • 29
124
votes
17 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
  • 6,000
  • 9
  • 30
  • 46
100
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,556
  • 10
  • 43
  • 55
86
votes
6 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
  • 66,414
  • 68
  • 253
  • 406
1
2 3
99 100