July 29, 2009 at 11:42 AM
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("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//Database";);
File[] files = folder.listFiles();
File file=new File("
C://Answers//DataBase//DataBaseExamples.jar";);
jar.createJarArchive(file, files);
}
}
Hope that it will be helpful for you.
Thanks
Related Tutorials/Questions & Answers:
jar file - Java Beginners an application packaged as a
JAR file (requires the Main-class manifest header)
java -
jar...
jar file
jar file When creating a
jar file it requires a manifest... options in
jar file. What is
Jar File?
JAR files are packaged in the zip
Jar file - Java BeginnersJar file Hello
this is my second question and i hope atleast i will get answer
i bulid a
jar file of my project using netbeans but now problem is when i open that
jar file in command prompt i got error exception in thread
Advertisements
Java Jar File - Java BeginnersJava Jar File What is a
Java JAR file ..and how can i open a .
jar file in
Java? Just create a
Jar file and Double click on it, it will automatically runs main method in that
Jar : to create Project as
JAR java jar file - Java Beginnersjava jar file How to create
jar Executable File.Give me simple steps to create
jar files Hi Friend,
Try the following code:
import...();
System.out.println("
Jar File is created successfully.");
} catch (Exception ex
Create JAR file - Java Beginners. But do let me know, isn't there any other way of making a
JAR File. Simply like... to make a
JAR file and run it easily on any computer. For that purpose i want to make my .class files to get converted into .
jar file.
More knowledge
Creating JAR File - Java Beginners me, in letting me know, as to how to create
JAR file from my
JAVA source...();
}
out.close();
fout.close();
System.out.println("
Jar File... main(String[]args){
CreateJar
jar=new CreateJar();
File folder = new
File Creating JAR File - Java BeginnersCreating
JAR File Respected Sir,
Thankyou very much for your..., which says, Failed to load Main-Class manifest attribute from H:\Stuff\NIIT\
Java... to change the contents of my manifest
file. I read somewhere regarding i have to add
Reading a file from Jar JAVAReading a
file from
Jar JAVA I have added one excel sheet into a
jar file.
can anybody tell me how i can read that
file.
actually when i am running code from eclipse i able to read it but when i am adding that
jar file Reading a file from Jar JAVAReading a
file from
Jar JAVA I have added one excel sheet into a
jar file.
can anybody tell me how i can read that
file.
actually when i am running code from eclipse i able to read it but when i am adding that
jar file jar filejar file how to create a
jar file in
java JAR FILE and applications.
The
Java Archive (
JAR)
file format enables to bundle multiple...
JAR FILE WHAT IS
JAR FILE,EXPLAIN IN DETAIL?
A
JAR file... link:
Jar File Explanation
jar filejar file how to run a
java file by making it a desktop icon i need complete procedur ..through cmd
jar filejar file steps to create
jar file with example
jar filejar file
jar file where it s used
Java Execute Jar file operating system or platform.
To execute a
JAR file, one must have
Java... the program uses.
To Run your .
jar file type
java -
jar [
Jar file Name...
JAR stands for
Java ARchive and is platform independent. By making all
Creating a JAR file in Java 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
Java Jar File
Java Jar File
In
Java,
JAR (
Java ARchive) is a
platform-independent
file format that allows you... for reading and writing
the
JAR (
Java ARchive)
file format, which is based
java-jar file creation - Java Beginnersjava-
jar file creation how to create a
jar file?i have a folder... file Hi Friend,
JAR stands for the
Java Archive. This
file format is used to distribute a set of
java classes. This
file helps you to reduce the
file What is a JAR file in Java What is a
JAR file in
Java
... files in a
JAR file.
JAR stands for the
Java Archive. This
file format is
used...
java application in it. The
jar file can execute from the javaw (
Java Web
Start
how can create a jar file - Java Beginnershow can create a
jar file plz any one help me which
file can i create the
jar file plz give exact command Hi
The basic format of the command for creating a
JAR file is:
jar cf
jar-
file input-
file(s
change jar file icon - Java Beginnerschange
jar file icon How to create or change
jar file icon Hi friend,
The basic format of the command for creating a
JAR file is:
jar cf
jar-
file input-
file(s)
* The c option indicates that you want
Only change jar file icon - Java BeginnersOnly change
jar file icon Dear Friend
I know that how to create a
jar file but i don't know How to change
jar file Icon.
I can change .exe
file icon but i can't change .
jar file icon okk,
/// best help for me if you sent
Jar file - Java Server Faces QuestionsJar file Hi All,
What is the
Jar file to run The Jsf Applications.When i am trying to run in the Eclipse its not running.
Thanks in Advance,
Puppy
Hi friend,
Jar file to run The Jsf Applications
jsf
File path for jar fileFile path for
jar file Hi Experts,
I have created one eclipse...
jar file of that application, unfortunately it is giving the error that resource not found for the template
file.
Also I had tried to get that path from user
where located mysql jar file - Java Beginnerswhere located mysql
jar file pklz any one help me how can work with eclipse jsp and tomcatplz guide me
and give brief description
i have a
jdk 1.4
tomcat 4.0
mysql 5.0
and eclipse 3.1
plz guide me how can i
How to use JAR file in Java anywhere and run on any platform. All operating system support
Java.
JAR file...
JAR which stands for
Java ARchive allows a programmer to archive or collect... to digitally sign the
JAR file. Users who want to use the secured
file can check
How to Unjar a Jar file in JavaA
JAR file is a collection of
Java class files that contains images, methods....
JAR file in
Java simplifies distribution and makes it available across... that comes with a JDK.
Following are the steps to Unjar a
Jar file in
Java for Windows
Extract Jar FileExtract
Jar File How to extract
jar file?
Hi
Please open the command Prompt and to the
jar file and write the command
jar -xvf JaraFileName.jar
How to create a jar file???
The given code creates a
jar file using
java.
import java.io.*;
import...();
System.out.println("
Jar File is created successfully.");
} catch (Exception ex...How to create a
jar file Hello!!!!
I have a project which has
jar file with htmljar file with html I have a
jar file. On double click it shows an applet page. Please tell me how to connect that applet into html or jsp page
Creating an executable jar fileCreating an executable
jar file When I try to create jar.exe through CMD, the manifest
file created doesn't contain Main-Class attribute, even though it is included in text
file used during creation of
jar file JAR File - Swing AWTJAR File Is there anybody to solve my problem of not executing the
JAR file?
I have asked the question previously but I haven't got any answer yet. Please help me
struts jar file problemstruts
jar file problem hi..
I'm using struts-core-1.3.9.jar.
it works well if am using ma application with internet
but
it shows me an error while initializing ActionServlet when i disconnected to Internet
The error stack trace
How to Create Jar File using JavaHow to Create
Jar File using
Java Programming Language
A
Jar file combines... is the code for
Java Jar File Function:
import java.io.*;
import ... in the
jar file. In this section, we are going to create our own
jar file jar File creation - Swing AWT in
java but we can create executable
file in
java through .
jar file..
how can i convert my
java file to
jar file?
Help me...
jar File creation I am creating my swing applications.
How can i
Viewing contents of a JAR File
Viewing contents of a
JAR File
This section shows you how you can read the content of
jar file... the contents of the
jar file without
extracting it. You can easily understand about
Changing Executable Jar File IconChanging Executable
Jar File Icon I have created an executable
jar file for my
java program and the icon that appears is the
java icon. I will like...;Hi,
You may use JSmooth to create executable
java file and also associate icon
Executing JAR file - Swing AWT created the
JAR file of my project with the Manifest
File including my Main... Manifest.txt secl/*.class
and my
jar file is created. But there is a problem, when I execute this
jar file at command prompt by the following command:
C
creating a jar file - JSP-Servletcreating a
jar file Can you give me detail answer
1. i am having a servlet.class
file in classes folder
2. web.xml
file
my questions are
1. where to place the html or jsp files
2. how to create a
jar file and how can
Jar file creation - Swing AWTJar file creation i have developed a swing application using Net... the application i gets a
JAR file a lib
file is also created in dist folder..this wrks fine using IDE
1.Now i want to give the application as a
jar file requesting for a jar file - Development processrequesting for a
jar file Sir Please send me a
jar file of this sir , i need this package
jar file org.apache.poi.hssf.usermodel for Excel reading /Writing in
java please help me.
thanks in advance.... Hi Friend
including jar file in maven pom.xml including
jar file in maven pom.xml Hi,
I want to include a
jar file from the WEB-INF/lib folder. Please let's know how to to do this?
Thanks....
Add the following code into your pom.xml
file and the error will go away
down load jar file - JavaMaildown load
jar file i want to down load james2.1.3 file.where is location it got it. Hi Friend,
You can download James Server from the following link:
http://james.apache.org/download.cgi
Thanks