473,326 Members | 2,438 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 473,326 developers and data experts.

Creating jar file in java

Creating a jar File in Command Prompt

Start Command Prompt.
------------------------
Navigate to the folder that holds your class files:
C:\>cd \mywork

Set path to include JDK’s bin. For example:
-------------------------------------------
If path & Classpath is set as environment variable then:
C:\mywork> javac

If not then for active session:
C:\mywork> set path ="c:\Program Files\Java\jdk1.5.0_09\bin"

Compile your class(es):
------------------------
C:\mywork> javac *.java
If File is packaged then:
c:\mywork> javac ./package/*.java

Create a manifest file:
-----------------------
Main-Class is the class which conatins void main method()
C:\mywork> echo Main-Class: ClassName>manifest.txt
If File contains package then
C:\mywork> echo Main-Class: Package.Classname>manifest.txt

WARNING: Manifest file should must not contain any space after Classname
----------

Create a jar file:
-----------------

Jar Option:

Create jar file
jar c[v0M]f jarfile [-C dir] inputfiles [-Joption]
jar c[v0]mf manifest jarfile [-C dir] inputfiles [-Joption]
jar c[v0M] [-C dir] inputfiles [-Joption]
jar c[v0]m manifest [-C dir] inputfiles [-Joption]

Update jar file
jar u[v0M]f jarfile [-C dir] inputfiles [-Joption]
jar u[v0]mf manifest jarfile [-C dir] inputfiles [-Joption]
jar u[v0M] [-C dir] inputfiles [-Joption]
jar u[v0]m manifest [-C dir] inputfiles [-Joption]

Extract jar file
jar x[v]f jarfile [inputfiles] [-Joption]
jar x[v] [inputfiles] [-Joption]

List table of contents of jar file
jar t[v]f jarfile [inputfiles] [-Joption]
jar t[v] [inputfiles] [-Joption]

Add index to jar file
jar i jarfile [-Joption]

C:\mywork> jar cvfm JarFile.jar manifest.txt *.class

for Package classfile:
C:\mywork> jar cvfm JarFile.jar manifest.txt ./Package/*.class

for Including other files in Jar
C:\mywork> jar cvfm JarFile.jar manifest.txt ./Package/*.class ./Package/*.xml ./Package/*.jpeg
or
C:\mywork> jar cvfm JarFile.jar manifest.txt ./Package/*.class ./Package/ABC.xml ./Package/config.Properties

Info: Include all the required files also in jar creation option.
-----

now if UR Jar file is created then run
C:\mywork>java -jar JarFile.jar {Arguments if any}


Also Refer http://download.oracle.com/javase/1.4.2/docs/tooldocs/windows/jar.html

By Kuldeep Sharma @ 19th December 2011.
Dec 19 '11 #1
0 3825

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Jan Danielsson | last post by:
Hello all, Is there any way to create a file with a specified size?
7
by: Selden McCabe | last post by:
I'm using the following code to write some text to a file: objWriter = New StreamWriter(FullPath, True, System.Text.Encoding.ASCII) For nRow = 1 To sData.Length - 1...
0
by: reidarT | last post by:
Ugyldig på toppnivået av dokumentet. Feil under behandling av ressursen file:///C:/VB/WebBrowser/WebBrowserControl/TESTFILE... "<?xml version=""1.0""?>","<XMLTest>" ^FileOpen(1,...
1
by: ReidarT | last post by:
The former post was wrong, the lines where concatenated so here it goes again. I am wrriting to a file (XML-format) and using FileOpen(1, "C:\vb\WebBrowser\WebBrowserControl\TESTFILE.XML",...
2
by: sreek518 | last post by:
hi, anyone have ideas regarding how to create a java IDE. can u pls specify the steps involved in creating the IDE, also with links where I can get necessary information. ( actually we are final...
4
by: joerozario | last post by:
In .net 2005 I have created Application I want to create a log file, which maintains all the internal process so at the run time I want to create a file at the source Code: Private string...
1
by: banging | last post by:
Hi there, I have a question regarding locking of tables so that when two or more people try to write or update the mysql tables, it locks up. Basically I only want one person to write to the...
3
by: XDeveloper | last post by:
Hi Dear Fellows! I recently have passed Java! And I choose C++ way! So and now I need to understand how can I built below problem! With a binary file operations of addition, removal and...
0
by: danielmessick | last post by:
Hey all !! I'm having a frustrating time trying to create a particular Java applet for a class.. I have no clue how to accomplish this, and really need HELP.. Anyone, PLEASE help me if you can, any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.