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
2 answers

Exclude test class directory for archiving in Ant

I have created a java library project. The binaries are available at /bin. The test classes are available at /bin/com/myproject/test. I need to exclude archiving of my test classes. So, I wrote the following code:
bdhar
  • 21,619
  • 17
  • 70
  • 86
5
votes
7 answers

eclipse project not importing the jar packages in local Maven repository

I am facing a problem in setting my eclipse project. The problem is whenever I am creating a new project and import the code.Eclipse is not resolving the packages which are present in the jar files which are present in the…
code4fun
  • 2,661
  • 9
  • 25
  • 39
5
votes
1 answer

Load application.properties outside jar

How can I set application.properties in SpringBoot outside .jar? I would link to this file and load properties from code.
Riccardo Califano
  • 1,317
  • 3
  • 10
  • 19
5
votes
2 answers

FileSystemNotFoundException while running JAR (Fxyz3d library)

I built a quite fat JavaFX application (the JAR is about 128 MB) and I got no problem in running in through IntelliJ. But when I run it from the terminal my 3D model loaders (Fxyz3d library) launch this exception. Exception in thread "JavaFX…
anonymflaco
  • 158
  • 1
  • 10
5
votes
2 answers

Cannot use jar command on windows

The jar command is not working on my box. I have downloaded the jdk, and set the envar "Path" to include the path to the jdk \bin directory. However, I still get that annoying message, "'jar' is not recognized as an internal or external command,…
MirroredFate
  • 12,396
  • 14
  • 68
  • 100
5
votes
1 answer

How to debug code by stepping into jar file code for which I have the source code in Visual Studio Code?

I am a C#, c++ developer. If I have the code and pdbs to external dlls, I am able to step into the code of the external dll, by pointing IDE to the code and/or the PDBs. I want to do something similar with Java JARs I have created a Micro Service…
Anand
  • 316
  • 1
  • 14
5
votes
1 answer

Where do I get the JOGL JAR?

This might sound silly... but I don't know where to find the JOGL JAR. I searched their website (http://jogamp.org/jogl/www/) and couldn't find it. Could someone please help? Thank you blargman
nambvarun
  • 1,201
  • 4
  • 13
  • 14
5
votes
1 answer

How exclude all test jars* from mvn dependency:tree

is there any way to exclude dependencies used during test goal? For example I would like to avoid having all *:tests jar printed by mvn dependency:tree. [INFO] Building test 1.0-SNAPSHOT [INFO]…
Prisco
  • 653
  • 1
  • 15
  • 30
5
votes
2 answers

Adding custom tags to jar manifest

I have a requirement wherein I wanted to put some user defined tags in jar manifest file. I was wondering if it is possible to do so? If yes, any example? if no. :( why not?
test
  • 51
  • 1
  • 2
5
votes
1 answer

Embedding the WSDL for a web service in a JAX-WS client .jar

I have a web service that was created several years ago in C++ and is consumed by a .NET client using C#'s "wsdl.exe" to generate the client stubs. For a variety of reasons, I now also need a Java client and am willing to restrict usage to Java 6…
Austin Ziegler
  • 776
  • 10
  • 17
5
votes
2 answers

Deploying .jar file: Why can't I load icon files?

I'm exporting a simple java project that includes two directories; src and Icons. Icons is a directory that contains three .png files. I'm exporting to an executable .jar file using File -> Export. The export works properly and the .jar file…
None
5
votes
2 answers

Elegant way to compare the content of JARs (to find new classes and methods)

Yes, the Internet says - "unzip them all, decompile and compare the code with some tool (total comander, WinCompare, meld(linux), whatever...) The reason why I need a tool to generate difference report automatically from Fodler1 and Folder2 is…
JackBauer
  • 135
  • 1
  • 3
  • 10
5
votes
3 answers

how to exclude external jar while creating executable jar in eclipse or commandline?

I have written a program in Eclipse IDE which uses BouncyProvider class of BouncyCastle.jar. So to compile my class I added BouncyCastle.jar in my project classpath and it compiles perfectly. Now I want to export my project as Runnable JAR so when I…
Jenish
5
votes
0 answers

How to create a jar file from a javaFX application with all module dependencies from command line?

I have a javafx application and I want to compress it and its module dependencies (javaFX) into a single jar file via windows command prompt, so that you can run it via double click anywhere without needing the javafx sdk. The javaFX modules I'm…
Kein
  • 348
  • 1
  • 3
  • 15
5
votes
0 answers

How to list files inside a JAR?

I have a Java application that uses a JAR. The JAR has some resource files which it accesses from its own class. In the jar, this lists the resource files present in the targets/classes folder: ClassLoader loader =…
awesomemypro
  • 531
  • 1
  • 11
  • 32
1 2 3
99
100