what are .jar files?

Manish Goyal

Manish Goyal

@manish-r2Hoep Oct 21, 2024
can anyone tell me what are .jar files and how can we create it?
I know these files play an important role in setting up a environment for a software..so that it can be installed..?
Please tell me the whole procedure for this??

Replies

Welcome, guest

Join CrazyEngineers to reply, ask questions, and participate in conversations.

CrazyEngineers powered by Jatra Community Platform

  • Mahesh Dahale

    Mahesh Dahale

    @mahesh-E2tZ3t Jan 4, 2010

    JAR (Java Achieve Files) are compressed files that are used to bundle multiple
    files into a achieve file so the distribution can be managed easily.

    JDK includes a JAR tool that is used for creating JAR files.

    also use JCreator

    <a href="https://www.skylit.com/javamethods/faqs/createjar.html" target="_blank" rel="nofollow noopener noreferrer">Creating an Executable jar File</a>

    #-Link-Snipped-#
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Jan 4, 2010

    Thanks for these links...i will try it...if there will be further queries ..will post it here
    Thanks again
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Jan 5, 2010

    Guys it is going to be very tough for me to understand..how to create a executable jar files?
    can anyone please take some time and explain how to create executable jar file?Pleaseeeee
  • Morningdot Hablu

    Morningdot Hablu

    @morningdot-6Xuj4M Feb 3, 2010

    goyal420
    Guys it is going to be very tough for me to understand..how to create a executable jar files?
    can anyone please take some time and explain how to create executable jar file?Pleaseeeee
    hai goyal it,s simple right click on the file of which exe file you want to creat and then add to archive and give the archive name anything.exe......
    .
    finaly you got the exe file of thet file..../
  • shruti palod

    shruti palod

    @shruti-palod-Sarni8 Feb 3, 2010

    Hi Goyal
    Java Archive (JAR) files are compressed files into which you can store many files. If you place the many classes that your application, or applet need in a JAR file, you reduce the size of your distributabels.

    here is how you can create executable jar files:

    First, make sure you have installed Java 1.2 or above. This facility is not available in previous versions of Java.
    Next, create your working java system. In general, you will want to put it into a package. For this example, I created a trivial HelloWorld application that prints out "Hello World" plus the first command line argument, and placed it into the package "psae". Therefore, the HelloWorld files (HelloWorld.class, HelloWorld.java) were located in the directory psae. I tested the system to make sure it worked before going on to the next step.
    In the directory in which the psae is located, created a file called "mainClass". This file contains a single line specifying where the main Class is to be found in the jar file. Note that I use the package specification. Here is the single line:
    Main-Class: psae.HelloWorld
    Note: make sure you type a carriage return after this line; some windows systems need it and will report a "Failed to load Main-Class manifest attribute" error.
    Next, I create a jar file called psae.jar using the "jar" command in Java2. I use the "m" command line argument to specify the manifest file mainClass, which adds information to the jar file on where the main class will be found. Here is the jar command:
    bertha:~ > jar cmf mainClass psae.jar psae
    Just for fun, and to check what's happened, I print the table of contents for the jar file I just created. Here's the command and its result:
    bertha:~ > jar tf psae.jar
    META-INF/
    META-INF/MANIFEST.MF
    psae/
    psae/HelloWorld.java
    psae/HelloWorld.class
    Having successfully created the jar file, I can now invoke java2 on it with the command line argument:
    bertha:~ > java -jar psae.jar Philip
    Hello World Phili
  • Manish Goyal

    Manish Goyal

    @manish-r2Hoep Feb 3, 2010

    Thanks shruti