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
85
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
  • 29,632
  • 51
  • 171
  • 250
79
votes
8 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
  • 5,521
  • 8
  • 37
  • 74
76
votes
10 answers

Visual Studio Code, Java Extension, how to add a JAR to classpath?

In Eclipse IDE, I add a JAR library using Project > Build Path > Configure Build Path... What is the equivalent in VisualStudioCode? I had a look into launch.json. There is a classpath defined. Adding JARs to this classpath (array) variable seems…
gqp21
  • 761
  • 1
  • 5
  • 3
72
votes
7 answers

NoClassDefFoundError while trying to run my jar with java.exe -jar...what's wrong?

I have an application that I'm trying to wrap into a jar for easier deployment. The application compiles and runs fine (in a Windows cmd window) when run as a set of classes reachable from the CLASSPATH. But when I jar up my classes and try to run…
Ogre Psalm33
  • 21,366
  • 16
  • 74
  • 92
72
votes
3 answers

Why is my URI not hierarchical?

I have files in resource folder. For example if I need to get file from resource folder, I do like that: File myFile= new File(MyClass.class.getResource(/myFile.jpg).toURI()); …
grep
  • 5,465
  • 12
  • 60
  • 112
70
votes
4 answers

How to create a fat JAR with Gradle Kotlin script?

As titled, I'd like to know how to modify the gradle.build.kts in order to have a task to create a unique jar with all the dependencies (kotlin lib included) inside. I found this sample in Groovy: //create a single Jar with all dependencies task…
elect
  • 6,765
  • 10
  • 53
  • 119
60
votes
7 answers

Reference jars inside a jar

I have a jar whose content looks as shown below, Below is my manifest file Manifest-Version: 1.0 Ant-Version: Apache Ant 1.8.3 Created-By: 1.7.0_06-b24 (Oracle Corporation) Main-Class: org.sai.com.DerbyDemo Class-Path: derby.jar derbyclient.jar…
srk
  • 4,857
  • 12
  • 65
  • 109
59
votes
4 answers

Distributing my Python scripts as JAR files with Jython?

I have been a Python programmer for almost two years, and I am used to writing small scripts to automate some repetitive tasks I had to do at the office. Now, apparently my colleagues noticed this, and they want those scripts too. Some of them have…
sharat87
  • 7,330
  • 12
  • 55
  • 80
56
votes
18 answers

Not able to download Zip file from gmail which contains executable Jar in it

I have an email almost 4 years ago, which has Zip file in attachments containing executable jar file. I want to download that file. But, nowadays gmail doesn't allow to send or receive any executable file. Can anybody help me how can I download that…
Nijesh Hirpara
  • 1,096
  • 1
  • 12
  • 17
44
votes
4 answers

Create multiple runnable Jars (with dependencies included) from a single Maven project

I have a single maven project that has multiple main classes. I want to generate runnable Jars (that include all dependencies) out of these project. I currently have the following build configuration (using maven.assembly):
Martin Thurau
  • 7,564
  • 7
  • 43
  • 80
44
votes
10 answers

Execute .jar file from a Java program

How could I run a local jar file from a java program? The jar file is not in the class-path of the Java caller program.
vfgjrk
  • 443
  • 1
  • 4
  • 4
39
votes
1 answer

Strange behavior of Class.getResource() and ClassLoader.getResource() in executable jar

I understand from What is the difference between Class.getResource() and ClassLoader.getResource()? and from own code, that getClass().getResource("/path/image.png") is identical to getClass().getClassLoader().getResource("path/image.png") The…
Andreas Fester
  • 36,091
  • 7
  • 95
  • 123
37
votes
14 answers

Eclipse cannot create runnable jar - No resources selected

When I try to export my project as a runnable jar Eclise gives me the following error: No resources selected. The project runs fine within Eclipse, I already tried to clean the project before exporting, but that didn´t work. Any ideas on how to fix…
TrashCan
  • 817
  • 4
  • 13
  • 20
34
votes
3 answers

Start a jar file like service in linux

I want to start and stop my jar file as follows service myService start service myService stop my current jar file running as follows cd /home/alex/IdeaProjects/myService java -jar target/myService-SNAPSHOT-1.jar server config.yml What should I do?
Alex Mathew
  • 3,925
  • 5
  • 21
  • 25
34
votes
11 answers

How To stop an Executed Jar file

It feels like a dumb question to ask, but i cant seem to figure it out. when i run a *.jar file on windows it doesnt apears in the taskmanager processes. how can i terminate it , i have tried TASKKILL but it also doesnt work for me.
susparsy
  • 1,016
  • 5
  • 22
  • 38