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
32
votes
9 answers

"Could not find the main class" error when running jar exported by Eclipse

I have a java project that works perfectly fine when running it from within Eclipse. When I try to export it to either a "JAR file" or "Runnable JAR file" the .jar file is created, but when I double click on it to try to run the program it gives me…
scaevity
  • 3,991
  • 13
  • 39
  • 54
32
votes
1 answer

Minimize an Uber Jar correctly, Using Shade-Plugin

I am using the Maven-Shade-Plugin to create a runnable Uber-jar. According to the last frame on this page, the size of the jar can be minimized by using: true But this feature does…
summerbulb
  • 5,709
  • 8
  • 37
  • 83
32
votes
13 answers

Prevent launching multiple instances of a java application

I want to prevent the user from running my java application multiple times in parallel. To prevent this, I have created a lock file when am opening the application, and delete the lock file when closing the application. When the application is…
Sathish
  • 1,481
  • 5
  • 20
  • 33
31
votes
2 answers

Java command line with external .jar

I develop a project using .jar to reuse code. So I have on .jar named TOOLS.jar, and I develop a simple application in file HelloWorld.java which refer my package TOOLS from TOOLS.jar I compile with this command line: javac -g -d C:\MyApp -cp…
TheFrancisOne
  • 2,667
  • 9
  • 38
  • 58
31
votes
2 answers

How to include SQLite database in executable Jar?

I have created a Swing application that uses SQLite as a local database. The database file is located in project's root directory. Project/DatabaseFile The application runs fine on Eclipse, but when I run the packaged executable Jar, I get the…
Momo
  • 2,471
  • 5
  • 31
  • 52
30
votes
4 answers

Run a jar file using windows scheduler

I have jar file which I want to run from windows scheduler in windows 7 I have Given the path of java.exe in path/script and -jar c:\abc\ab.jar in the arguments field. But it does not run. I have also tried it with help of a bat file, but it does…
Nitesh
  • 485
  • 1
  • 6
  • 12
29
votes
2 answers

Selecting main class in a runnable jar at runtime

I have two main classes in the app. When I package it to a runnable jar (using Eclipse export function) I have to select a default main class. Is there a way to access the non-default main class from the jar at runtime?
Tomasz
  • 5,269
  • 8
  • 56
  • 65
29
votes
7 answers

assembly-merge-strategy issues using sbt-assembly

I am trying to convert a scala project into a deployable fat jar using sbt-assembly. When I run my assembly task in sbt I am getting the following error: Merging 'org/apache/commons/logging/impl/SimpleLog.class' with strategy 'deduplicate' …
sc_ray
  • 7,803
  • 11
  • 63
  • 100
27
votes
2 answers

Jersey exception only thrown when depencencies assembled into a single jar

I'm writing a server that embeds Jetty w/ Jersey. When I execute from Eclipse, everything is great. However, if I assemble my server and all dependencies into a single jar using Maven's assembly:single goal, I get an exception: Sep 26, 2012…
HolySamosa
  • 9,011
  • 14
  • 69
  • 102
25
votes
4 answers

Specifying Log4j2 Configuration File When Using Executable JAR

I am having trouble specifying the Log4j2 config file location when using an executable JAR file. It works fine if I separate all the JARs, but when I try to combine them into one executable JAR file, for some reason the log4j2.xml file isn't picked…
Steph
  • 2,135
  • 6
  • 31
  • 44
23
votes
3 answers

What is the best way to deploy JavaFX application, create JAR and self-contained applications and native installers

I'm using IntelliJ IDEA, and I have my JavaFX application ready for deployment. The problem is that when I generate the JAR file, it won't run, when I run it in the command line, I get an Exception, FXMLLoadException, although the project is working…
Jean-Baptiste-B
  • 325
  • 1
  • 3
  • 9
23
votes
4 answers

Create deployable JRuby JAR file?

I need to compile my JRuby application into a standalone JAR file. How can I do this?
PythonGem
  • 491
  • 1
  • 5
  • 9
23
votes
2 answers

Set Icon for executable Jar file

I have a simple executable Jar file. How I can set icon for this file? In my case I use the standard Jar icon which I would like to change.
Peter Penzov
  • 1,126
  • 134
  • 430
  • 808
23
votes
1 answer

Maven Build is not including .class file in jar

I have looked through everything I can find on StackOverflow and I could not find an answer. I have just built out a new machine and I have projects that compiled and built on previous installations just fine. But my new machine won't. Everything…
John Blakie
  • 729
  • 1
  • 6
  • 7
22
votes
1 answer

SBT project for java executable jar

What is the best way to set the target package for an SBT project to be an executable jar file? It would need to bundle scala-library.jar and set the manifest for main-method.
Synesso
  • 37,610
  • 35
  • 136
  • 207