Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest 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).

 

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.

                         

» View all related tutorials
Related Tags: c string reference io method type boolean key rmi ole this ai node oo create if boo example to contains

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

Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

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 | Flex 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.