Results 1 to 5 of 5

Thread: How to create an executable jar?

  1. #1
    Join Date
    Apr 2010
    Posts
    57

    How to create an executable jar?

    I have recently started doing an advanced Java coding, so I am not having much knowledge about it. I want to create an executable java archive. Since, I am new to this topic, I am not having any idea about it. Then I thought to take some assistance from you members because you explain the things very clearly. . Please help me in solving my problem. The only thing I want to know now is how to create an executable jar? Any sample coding would be much grateful.!!

  2. #2
    Join Date
    Mar 2008
    Posts
    227

    Re: How to create an executable jar?

    Firstly, you should create a Manifest file. This file will contain the name of the class to run and archives to put in the CLASSPATH.

    Code:
    Manifest - Version: 1 . 0 Created - By: 1 . 4 .1_01 (Sun Microsystems Inc.) Main - Class: Start Class - Path: . / archive1.jar . / archive2.jar
    We call the MANIFEST.MF file and it will be placed in a directory called META-INF in the application root (for example). The jar archive of the classpath will not be included in this jar, but will be located subsequently in the same directory that we create (or in a well-defined path). If they are to be stored in a directory it will suffice to give the path:

    Code:
    Class-Path: path1/archive1.jar path2/archive2.jar

  3. #3
    Join Date
    Mar 2008
    Posts
    232

    Re: How to create an executable jar?

    To create the jar must already deleted all .Java files. The ideal is to copy all. Class (with their tree if they are packaged) in a temporary directory to create the jar in this directory. You can also copy the files to be accessible in the jar (pictures) if any. The command to create a file .Jar is as follows :
    jar cvfm file-jar file-manifest files...

    That is the meaning of different parameters:
    • jar-file: is the name of the jar to create
    • file-evident: MANIFEST.MF file
    • files: add files to the archive. If a file is a directory, it is processed recursively.

  4. #4
    Join Date
    Apr 2008
    Posts
    193

    Re: How to create an executable jar?

    In the directory. Class, then you will execute the following command :
    jar cvfm myapp.jar META - INF / MANIFEST.MF
    This is going to create one. myapp.jar named executable jar file with this MANIFEST.MF in the META / INF. This jar is seen to add files in current directory (specified by the character'.'). The program will rebuild the jar Manifest file and display the standard output the results (it can verify that it is encoded correctly).
    It then runs the jar as follows:
    java -jar myapp.jar
    The files described in the Manifest Class-Path will be searched according to their path relative to the main jar file.

  5. #5
    Join Date
    Dec 2008
    Posts
    183

    Re: How to sign a JAR?

    You should also know how to sign a JAR? It must first generate a certificate:
    • keytool -genkey -alias signature -keystore myStore

    It must then respond to various questions (name, company, address ,....) This generates a certificate "signature" that is stored in a repository "Mystores". Then to sign the jar:
    • jarsigner -keystore myStore -signedjar smyJar.jar myJar.jar signature

    This generates the jar "smyJar.jar" which is the version signed with the certificate "signed" the jar "myJar.jar.

Similar Threads

  1. Ubuntu 10.04: Executable Bit
    By Yago16 in forum Operating Systems
    Replies: 5
    Last Post: 14-01-2011, 10:06 PM
  2. VB6 executable cannot be run on Windows 7 64 bit
    By The!Winston in forum Software Development
    Replies: 5
    Last Post: 23-12-2010, 08:00 AM
  3. Can i create an auto executable jar file for fx script
    By Jona-thon in forum Software Development
    Replies: 5
    Last Post: 23-07-2010, 03:39 AM
  4. How to make a bat executable?
    By Kasper in forum Operating Systems
    Replies: 4
    Last Post: 27-03-2010, 06:28 PM
  5. Cannot Run a .NET executable file ?
    By Akshita in forum Operating Systems
    Replies: 3
    Last Post: 25-02-2009, 06:15 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,711,722,015.77479 seconds with 17 queries