Java Steps

Java Steps

View Answers

September 10, 2009 at 5:35 PM

Hi Friend,

Try the following code:

import java.io.*;
import java.util.jar.*;

public class CreateJar {
public static int buffer = 10240;
protected void createJarArchive(File jarFile, File[] listFiles) {
try {
byte b[] = new byte[buffer];
FileOutputStream fout = new FileOutputStream(jarFile);
JarOutputStream out = new JarOutputStream(fout, new Manifest());
for (int i = 0; i < listFiles.length; i++) {
if (listFiles[i] == null || !listFiles[i].exists()|| listFiles[i].isDirectory())
System.out.println("-----------------------------------");
System.out.println("Adding " + listFiles[i].getName());
JarEntry addFiles = new JarEntry(listFiles[i].getName());
addFiles.setTime(listFiles[i].lastModified());
out.putNextEntry(addFiles);

FileInputStream fin = new FileInputStream(listFiles[i]);
while (true) {
int len = fin.read(b, 0, b.length);
if (len <= 0)
break;
out.write(b, 0, len);
}
fin.close();
}
out.close();
fout.close();
System.out.println("Jar File is created successfully.");
} catch (Exception ex) {}
}
public static void main(String[]args){
CreateJar jar=new CreateJar();
File folder = new File("c://Answers//Examples";);
File[] files = folder.listFiles();
File file=new File("C://Answers//Examples//examples.exe";);
jar.createJarArchive(file, files);
}

}

Hope that it will be helpful for you.
Thanks









Related Tutorials/Questions & Answers:
Java Steps - Development process
Java Steps  what are the steps to be taken to create a mobile phone compatible java swing program
Java Steps - Java Beginners
Java Steps  How to create Execuateable EXE File of Java Program.  Hi Friend, Try the following code: import java.io.*; import java.util.jar.*; public class CreateJar { public static int buffer = 10240
Advertisements
Java Problem Steps - Swing AWT
Java Problem Steps  How to create a Jar File From the Dos prompt of a Swing program having two classes in the program with one is public class one of them
Steps not found.
Steps not found.  import java.io.*; import java.net.*; import javax.servlet.*; import javax.servlet.http.*; public class Details1 extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse
Basic Steps to Outsourcing Success, Steps to Success in Outsourcing
Basic Steps to Outsourcing Success Introduction There are a few fundamental steps to ensure the best results for your outsourcing venture. These strategies... the decision making process in-house, these are the steps that need to be followed
I want simple steps to create Jar File of Java Project - Java Beginners
I want simple steps to create Jar File of Java Project  Hello Sir How I can Create Jar File of Java Project,plz Help Me  Hi Friend, Steps: 1. Start Command Prompt. 2. Navigate to the folder that holds your
steps to create desktop application in java swing using eclipse with drag and drop options
steps to create desktop application in java swing using eclipse with drag and drop options  please help to create desktop application in java swing using eclipse with drag and drop and what are the plugins required
Explain the process of implementing a CORBA client using a Java programming example and the steps involved.
Explain the process of implementing a CORBA client using a Java programming example and the steps involved.  plz tell me answer of this question... the process of implementing a CORBA client using a Java programming example
what are the steps in jdbc?
what are the steps in jdbc?  what are the steps in jdbc
Steps for the payment gateway processing?
Steps for the payment gateway processing?  Steps for the payment gateway processing
ModuleNotFoundError: No module named 'STEPS'
ModuleNotFoundError: No module named 'STEPS'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'STEPS' How to remove the ModuleNotFoundError: No module named 'STEPS'
ModuleNotFoundError: No module named 'STEPS'
ModuleNotFoundError: No module named 'STEPS'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'STEPS' How to remove the ModuleNotFoundError: No module named 'STEPS'
Steps to log4j configuration in Struts2
Steps to log4j configuration in Struts2  Hi... any tel me each step for configure log4j in struts2 application
data wrangling steps
data wrangling steps  Hi, I am beginner in Data Science and machine learning field. I am searching for the tutorials to learn: data wrangling steps Try to provide me good examples or tutorials links so that I can learn
steps required to execute a query in JDBC
steps required to execute a query in JDBC  What are the steps required to execute a query in JDBC
steps to install jasper in Eclipse with example
steps to install jasper in Eclipse with example   steps to install jasper in Eclipse with example
steps to install jasper in Eclipse with example
steps to install jasper in Eclipse with example   steps to install jasper in Eclipse with example
steps to install jasper in Eclipse with example
steps to install jasper in Eclipse with example   steps to install jasper in Eclipse with example
ModuleNotFoundError: No module named 'django-steps'
ModuleNotFoundError: No module named 'django-steps'  Hi, My Python... 'django-steps' How to remove the ModuleNotFoundError: No module named 'django-steps' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-steps'
ModuleNotFoundError: No module named 'django-steps'  Hi, My Python... 'django-steps' How to remove the ModuleNotFoundError: No module named 'django-steps' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pas.cmfextensions.update_steps'
ModuleNotFoundError: No module named 'pas.cmfextensions.update_steps' ...: No module named 'pas.cmfextensions.update_steps' How to remove the ModuleNotFoundError: No module named 'pas.cmfextensions.update_steps' error
ModuleNotFoundError: No module named 'pas.cmfextensions.update_steps'
ModuleNotFoundError: No module named 'pas.cmfextensions.update_steps' ...: No module named 'pas.cmfextensions.update_steps' How to remove the ModuleNotFoundError: No module named 'pas.cmfextensions.update_steps' error
ModuleNotFoundError: No module named 'pytest-steps'
ModuleNotFoundError: No module named 'pytest-steps'  Hi, My Python... 'pytest-steps' How to remove the ModuleNotFoundError: No module named 'pytest-steps' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-steps'
ModuleNotFoundError: No module named 'django-steps'  Hi, My Python... 'django-steps' How to remove the ModuleNotFoundError: No module named 'django-steps' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'django-steps'
ModuleNotFoundError: No module named 'django-steps'  Hi, My Python... 'django-steps' How to remove the ModuleNotFoundError: No module named 'django-steps' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'pas.cmfextensions.update_steps'
ModuleNotFoundError: No module named 'pas.cmfextensions.update_steps' ...: No module named 'pas.cmfextensions.update_steps' How to remove the ModuleNotFoundError: No module named 'pas.cmfextensions.update_steps' error
ModuleNotFoundError: No module named 'test_steps'
ModuleNotFoundError: No module named 'test_steps'  Hi, My Python... 'test_steps' How to remove the ModuleNotFoundError: No module named 'test_steps' error? Thanks   Hi, In your python environment you
ModuleNotFoundError: No module named 'flake8-oist-steps'
ModuleNotFoundError: No module named 'flake8-oist-steps'  Hi, My... named 'flake8-oist-steps' How to remove the ModuleNotFoundError: No module named 'flake8-oist-steps' error? Thanks   Hi, In your
Steps to read text file in pyspark
Steps to read text file in pyspark  Hi, I am learning to write... code. What are the Steps to read text file in pyspark? How much time it takes... are the steps to read a text file in Pyspark. You have to first import
What are the steps of a data analysis process?
What are the steps of a data analysis process?  Hi, How data analysis is performed in Big Data environment? What are the steps of a data analysis... technologies are involved at each phase. Let's see the steps of Data Analysis
Steps to Success in Offshore Outsourcing,Ten Successful Steps in Offshore Outsourcing
Offshore Outsourcing - Ten Steps to Success Here are a few must-follow steps when you go for offshore outsourcing. These steps are very useful in selecting a suitable vendor and planning out the entire process. The first step
program that uses while loops to perform the following steps :
program that uses while loops to perform the following steps :  Write a program that uses while loops to perform the following steps : a. Prompt... inclusive f. Output all the uppercase letters. (java coding: pls help me
JDBC Steps ? Basic steps in writing a JDBC Application
JDBC Steps – Basic steps in writing a JDBC Application... you brief description of JDBC Steps for making connection with the database.... Here are the JDBC Steps to be followed while writing JDBC program
steps to upgrade cPanel MySQL 5.1 to 5.5
steps to upgrade cPanel MySQL 5.1 to 5.5   steps to upgrade cPanel MySQL 5.1 to 5.5
steps to upgrade mysql 5.1 to 5.5 mac
steps to upgrade mysql 5.1 to 5.5 mac  steps to upgrade mysql 5.1 to 5.5 mac
Steps to execue jsp in jcreator - Development process
Steps to execue jsp in jcreator  Hi Friends, Can anyone give steps for executing jsp and servlets using Jcreator IDE
ModuleNotFoundError: No module named 'behave-models-steps'
ModuleNotFoundError: No module named 'behave-models-steps'  Hi, My... named 'behave-models-steps' How to remove the ModuleNotFoundError: No module named 'behave-models-steps' error? Thanks   Hi
ModuleNotFoundError: No module named 'azureml-contrib-pipeline-steps'
ModuleNotFoundError: No module named 'azureml-contrib-pipeline-steps' ...: No module named 'azureml-contrib-pipeline-steps' How to remove the ModuleNotFoundError: No module named 'azureml-contrib-pipeline-steps' error
ModuleNotFoundError: No module named 'behave-models-steps'
ModuleNotFoundError: No module named 'behave-models-steps'  Hi, My... named 'behave-models-steps' How to remove the ModuleNotFoundError: No module named 'behave-models-steps' error? Thanks   Hi
ModuleNotFoundError: No module named 'azureml-pipeline-steps'
ModuleNotFoundError: No module named 'azureml-pipeline-steps'  Hi...: No module named 'azureml-pipeline-steps' How to remove the ModuleNotFoundError: No module named 'azureml-pipeline-steps' error? Thanks   Hi
Deployment Steps in Weblogic Server - Development process
Deployment Steps in Weblogic Server  Hi Friends, Can anyone give me steps for Deploying application in web logic server ( both versions 8.1 and 9.2 ) with Eclipse IDE
Deployment steps in weblogic 102 - Development process
Deployment steps in weblogic 102   Hi Friends, can u give me d deployment steps in weblogic server 10.2(both jsp and servlet ..... how to export war file?) ..Thank u in advance
Steps For SSL Implementation/Enabling in Apache Tomcat 6.0
Steps For SSL Implementation/Enabling in Apache Tomcat 6.0   Hi , I am using the NetBeans 6.9 IDE Apache Tomcat 6.0 as Web server Front end jsp-servlet please gives me complete guidance steps ,code for SSL Implementation
Steps For SSL Implementation/Enabling in Apache Tomcat 6.0
Steps For SSL Implementation/Enabling in Apache Tomcat 6.0   Hi , I am using the NetBeans 6.9 IDE Apache Tomcat 6.0 as Web server Front end jsp-servlet please gives me complete guidance steps ,code for SSL Implementation
steps for installing mysql using msi package
steps for installing mysql using msi package  how to install mysql using msi package   Hello Friend, MySQL is open source database. Here is the link for the page from where you can understand how to Download
pls provide steps to connect mysql in flex - XML
pls provide steps to connect mysql in flex   hi ,PLS SUGGEST ME I HAVE NO IDEA WHERE TO PLACE THE FUNCTIONS.PHP CODE.I HAVE WAMP SERVER .CAN I PASTE THE FUNCTIONS.PHP THERE .OR ANY OTHERWAY .HOW FLEX CONNECT WITH WAMP .IF SO PLS
What are the steps to install R programming language?
What are the steps to install R programming language?  Hi, I am mathematics expert and and I want to learn R Programming. What are the steps to install R programming language? Thanks   Hi, I will tell you the steps
JSF Tutorials: Easy steps to learn JSF
JSF Tutorials: Easy steps to learn JSF JavaServer Faces or JSF is a web application based on Java programming language used for building component-based user... is a part of Java Platform and was formalized as a standard through the Java
pls provide steps to write ejb3.0 simple application in eclipse - EJB
pls provide steps to write ejb3.0 simple application in eclipse   hi, pls provide steps to create simple ejb3.0 application in eclipse .And also how to create entity bean ,session bean in ejb3.0
ModuleNotFoundError: No module named 'openml-speed-dating-pipeline-steps'
ModuleNotFoundError: No module named 'openml-speed-dating-pipeline-steps' ...: ModuleNotFoundError: No module named 'openml-speed-dating-pipeline-steps' How to remove the ModuleNotFoundError: No module named 'openml-speed-dating-pipeline-steps

Ads