Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 25-07-2010
Member
 
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.!!
Reply With Quote
  #2  
Old 25-07-2010
Member
 
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
Reply With Quote
  #3  
Old 25-07-2010
Member
 
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.
Reply With Quote
  #4  
Old 25-07-2010
Member
 
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.
Reply With Quote
  #5  
Old 25-07-2010
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , , , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


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


All times are GMT +5.5. The time now is 06:24 PM.