Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Creating a JAR file in Java

                         

This section provides you to the creating a jar file through the java source code by using the jar tool command which is provided by the JDK (Java Development Kit). Here, you can learn how to use the jar command, which is used in the dos prompt, in the java source code to perform same operations.

Following program is given for best illustration about using the dos used command in the java source code to perform the appropriate tasks. This program has been used the jar command "jar cf jar-file-name directory-name" in the source code to create a jar file for the given directory. You can also specify the file name(s) to collect it into the jar file format.

Code Description:

Runtime:
Runtime is the class of java.lang.*; package of Java. This class helps application to interface with the environment in which the java application is running.

Runtime.getRuntime():
This method gets the current runtime environment.

Runtime.exec(String[] command):
This method helps you to run the command of that environment in which your java application is running.

Here is the code of the program:

import java.io.*;

public class CreateJar{
  public static void main(String[] argsthrows IOException{
    if(args.length <= 0){
      System.out.println("Please enter the command.");
      System.exit(0);
    }
    else{
      Runtime.getRuntime().exec(args[0" " + args[1" " + args[2" " + args[3]);
    }
  }
}

Download this example.

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 

Current Comments

1 comments so far (
post your own) View All Comments Latest 10 Comments:

It s very useful site

Posted by Prashant on Friday, 06.15.07 @ 12:52pm | #19299

Latest Searches:
validating form using
interactive table
Java Tutorial
append message
prime number
ajax on spring
login form in swing
servlet and ajax
JGRAPH
jar entry
checkbox in servlet
window
Photoshop Buttons Crys
hibernate many to many
SimpleHelloByEnteringN
jsf with tomcat
<x:WorksheetSource HRe
sort array
<h:selectOneListbox
struts tags
passing select value
JDBC OCI
example program of sal
write.cs file in java
export to excel
ajax with jsp chat
typecast between strin
POI Excel
non-static method cann
swing animation
Error handling in stru
net use
architecture of servle
struts validation for
panelGrid
uml diagram for a scho
Easy UML Diagrams
cgi programming in per
input/output
hibernate3.0 jar file
data flow diagram
adding image in j2ee
Creating configuration
write a swing applicat
ะà¸??ะà¸?ย ะà
remote ip
how to get the time di
java session
s:iterate
JSTL API
source code for chat p
display the sum of 20
insert fields blob
word count in a file
how to get applicate s
pojo
Accessing Access Datab
java jtable
jQuery To Slide Effect
advantages of jsf
jar file for ActionSup
iterator
difference between arr
continue
jsf inpuDate example
types of webserver
flex
hibernate association
Arrays
jsf in struts
Create JTree using an
mathematics
count
JSF action lestner exa
insertion sort alphabe
Java examples on progr
html:button jsp exampl
swing
token string
Visual Basic Database
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.