473,626 Members | 3,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating jar file in java

22 New Member
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>manif est.txt
If File contains package then
C:\mywork> echo Main-Class: Package.Classna me>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.Properti es

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 3845

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

Similar topics

7
7497
by: Jan Danielsson | last post by:
Hello all, Is there any way to create a file with a specified size?
7
3924
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 objWriter.WriteLine(sData(nRow)) Next nRow objWriter.Flush() objWriter.Close() When I run this in the IDE, it works. When I compile it and run the EXE, it
0
1197
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, "C:\vb\WebBrowser\WebBrowserControl\TESTFILE.XML", OpenMode.Output) Write(1, "<?xml version=""1.0""?>") The error on top occurs when creating the file. I can see that the
1
1551
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", OpenMode.Output) Write(1, "<?xml version=""1.0""?>") ....
2
2524
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 year students, and we have decided to make a java IDE. with which we can understand parsing, java to xml to source tree, etc..). pls help. Regards, Sree...
4
2050
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 LogFileName = "ADM_Log.txt"; LogFileName = Application.ExecutablePath + "\\" + LogFileName;
1
3754
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 file, but many are able to read the files (or tables entities). I am not sure if I need to lock the tables in my Java code or do I lock the tables within the MySQL syntax. I'm just a little confused on the matter. This java code is a working...
3
2271
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 replacement of record are carried out. To write function by means of which primary input of the information from the keyboard and rewriting in a file is carried out. To write function, transformed data of an initial file to a text file in the form of the...
0
1243
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 help is appreciated the exact details are below: I'm trying to create an applet that will draw 200 lines all of the same length starting from coordinate (0, 0) each with a random color.After drawing each line call the method Wait.holdOn(10) to...
0
8262
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8196
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8637
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8364
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7192
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5571
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4090
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4196
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2623
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.