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:
To make java exe or runnable file
how to convert war file into .exe file using java code
Advertisements
how to run a .exe file in jsp
how to create an excel file using java
how to convert a jar file into .exe file
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?
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
how to create ipa file
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
Creating an exe file
Create new file in java
how to create notepad in java
how to create tar file in ubuntu
how to create tar file in ubuntu
conerting web project into .exe file
How to create a class in java
How to embedd jre inside the converted .exe file from .jar using Launch4J
How to create charts in Java?
How to Create Keyboard in JAVA
how to create a php script to download file
create table in mysql of split file created in java
How to create a jar file with database connection
how to create reports in swing java?
How to create a .mdf file from script (.sql)

Ads