how to create .exe file of java application??

Ads
 

how to create .exe file of java application??

View Answers

July 30, 2009 at 10:05 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("-----------------------------------");
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);
}

}

Thanks

June 22, 2012 at 12:35 AM

Thanks Dear,

I tested the program and it's running without any error ....

Pramoj

Ads









Related Tutorials/Questions & Answers:
how to create .exe file of java application?? - Java Beginners
To make java exe or runnable file
Advertisements
creating an .exe file - Java Beginners
how to convert war file into .exe file using java code
how to call an exe file from java - Java Beginners
how to run a .exe file in jsp
how to convert a jar file into .exe file
set java exe file as background - Java Beginners
how to start intergrated webcam of a laptop without calling its exe file using java only - Java Beginners
how to create an excel file using java
exe file creation - JDBC
how to create pdf file using java and itextjar
how to create pdf file using java and itextjar
How to convert many class files into one exe file?
How to convert many class files into one exe file?
how can create a jar file - Java Beginners
Creating an exe file
Server calling of .exe file in the client
how to create a jar file for java classes? - Java Interview Questions
conerting web project into .exe file
how to create ipa file
we can create our own header file in java?n how to create?
How To Create a New File
How to create a jar file
Create File in Java
Java MappedByteBuffer example, How to create a large size file in java.
How to embedd jre inside the converted .exe file from .jar using Launch4J
how to create a set up file of java web application
how to create a set up file of java web application
how to create a set up file of java web application
.EXE - Java Beginners

Ads