Questions tagged [jar]

JAR file (or Java ARchive) aggregates many files into one. JAR files build on the ZIP file format.

A file allows runtimes to efficiently deploy a set of classes and their associated resources. The elements in a JAR file can be compressed, which, together with the ability to download an entire application in a single request, makes downloading a JAR file much faster than separately downloading the many uncompressed files which would form a single Java Application. External libraries for Java language are very often represented as JAR files too. The package java.util.jar contains classes that read and write JAR files.

JAR file usually contains a manifest file - /META-INF/MANIFEST.MF. Manifest can contain additional meta information about the packaged code, such as version note, package vendor, packaging utility (e.g. ant or maven) used to build the package, implemented specification reference and so on. For executable JAR file manifest is mandatory.

JAR files can also be signed with a certificate to prevent unathorized modification. For Java applets and Java Web Start applications a proper JAR signature is quite important, as modern browsers won't trust unsigned or self-signed Java applications. Oracle jarsigner tool can be used for both JAR signing and signature verification.

Proper MIME type for JAR file is "application/java-archive".

To run your JAR file use: java -jar YourApp.jar

Frequently Asked Questions

People often ask these questions about this topic:

18886 questions
5
votes
0 answers

How to add resources to two module jars in same-named folders?

Assuming we have two jar files with two different modules. Both jar-files include some resources (lets say png-files) in a folder called images in their jar. When I now try to start a module in java I get the following error: Error occurred during…
5
votes
1 answer

How to load a resource from an embedded JAR File

I am trying to load a resource that is contained within an embedded JAR file. The project is actually deployed in JBoss using an EAR file with the following structure: deploy.ear | |-> project.sar | |-> sub_project.jar | | | |->…
cmcginty
  • 113,384
  • 42
  • 163
  • 163
5
votes
0 answers

JnativeHook creates freezing problem on MacOS

I'm doing a program that calculates keyboard mouse mobility on Windows, Mac, and Linux with JAVA. I'm using JNativeHook for get keyboard and mouse moves. It works fine in Windows and Linux, but after 10-15 minutes on MacOS , pc is freezing and I…
Yunus ER
  • 1,999
  • 2
  • 9
  • 14
5
votes
3 answers

How to Run Jar on java 7 compiled in java 8 or higher version

I have created a windows application using java 8 . But my client is using java 7 on his machine and not able to upgrade java on the machine. So when i run jar on java7 compiled in java 8 it gives error so can i convert jar compatible to lower…
adesh singh
  • 1,727
  • 9
  • 38
  • 70
5
votes
1 answer

Android Junit test - Mockito class not found exception

I'm attempting to build a unit test on Android which utilizes the mockito-all-1.8.5.jar file from mockito.org. I added the jar file to my project using project > properties > project build path > add external jar. This has always worked for me on…
Jack BeNimble
  • 35,733
  • 41
  • 130
  • 213
5
votes
0 answers

Reference uploaded JAR library

I've billed set of support function into helper.jar library and imported to Databricks cluster. The jar is installed on the cluster, but I'm not able to reference the functions in the library. The jar import has been tested, cluster restarted and…
Dan
  • 494
  • 2
  • 14
5
votes
1 answer

Spring DevTools not included in the fat jar packaged with spring-boot-maven-plugin

I am trying to create a fat jar using spring-boot plugin. But it keeps giving me NoClassDefFound exception. I have the following in my pom: org.springframework.boot
D.Tomov
  • 1,018
  • 2
  • 15
  • 36
5
votes
0 answers

IntelliJ IDEA - Decompiling/Editing/Recompiling JAR

I realize this may seem like a completely stupid question and this question is a "wall of text", but I'm feeling like I've gotten way out of my depth here and need some guidance. I've read several SO questions on this topic, but still can't seem to…
G_Hosa_Phat
  • 976
  • 2
  • 18
  • 38
5
votes
1 answer

Packaging Jar file for Mac and Windows without JRE bundled

I built in IntelliJ IDEA my javaFX application as jar file. Using "Project Structure >> Artifacts >> + JavaFX Application" I can build .app, .dmg, .pkg, .exe with JRE included. But I need build same files without JRE bundled. Sure, I can use JAR,…
Iga
  • 85
  • 5
5
votes
1 answer

package sun.security.ec does not exist

I'm trying to use sun.security.ec module in Java on Win7. When trying to compile, it gives this error: package sun.security.ec does not exist Where does sun.security.* reside in terms of a .jar file? Where can I download the .jar file?
trigger
  • 141
  • 1
  • 2
  • 3
5
votes
2 answers

Java - Rome rss reader?

I am trying to read rss. I copied the jar file in to my libs folder, and I added the jar file to my eclipse project as a library. In order and export i checked my jar file. Now I am trying to use the rss reader provided by rome import…
aryaxt
  • 76,198
  • 92
  • 293
  • 442
5
votes
3 answers

Can't import classes from jar

I am having problems importing classes from a JAR library into my project. Please see the screenshot. I have tried several things both in Eclipse and IntelliJ, both adding directly and adding through Maven. None of this helps, I still get a red…
vs97
  • 5,765
  • 3
  • 28
  • 41
5
votes
4 answers

Android include .jar in ant compilation

I try to include in my application compilation a .jar compiled. I use ant to compile my Android application. When I add this task to build.xml : compilation failed on android package importation…
TheFrancisOne
  • 2,667
  • 9
  • 38
  • 58
5
votes
1 answer

Create multiple shadowJars for each flavor of application

I'm experimenting with gradle and trying to setup a system that builds different flavors (brands) of an application, which differ by configuration mainly. What I have so far are two versions of the build scripts - both not working. Version 1 First…
Battlefury
  • 247
  • 1
  • 4
  • 20
5
votes
1 answer

How to Load File Outside of, but Relative to, the JAR?

I need to load a file outside of the JAR, but relative to it (lib/config/config.ini to be exact). I used that exact path, and it works fine as long as the working directory is where the JAR is, i.e. /path/to/jar$ java -jar JAR.jar If it's run like…
Jonah
  • 9,991
  • 5
  • 45
  • 79
1 2 3
99
100