Online Training Spring Hibernate Training in Delhi R Programming Training Course Big Data and Hadoop Training Java Training  

How to convert many class files into one exe file?



Share on Google+Share on Google+

Golla Tejesh Yadav
How to convert many class files into one exe file?
1 Answer(s)      6 years and 6 months ago
Posted in : Java Beginners

How to convert class files into one exe file? I have done my project in java.i want to know how to convert it into .exe file? plz reply fast. Thnx in Advance. Happy Pongal!

View Answers

January 14, 2011 at 1:39 PM

Hi Friend,

Happy Pongal!!!!

Here is your code:

import java.util.jar.*;
class OnlyExt implements FilenameFilter{
  String ext;
  public OnlyExt(String ext){
  this.ext="." + ext;
  public boolean accept(File dir,String name){
  return name.endsWith(ext);
public class CreateExe {
public static int buffer = 10240;
protected void create(File exefile, File[] listFiles) {
try {
byte b[] = new byte[buffer];
FileOutputStream fout = new FileOutputStream(exefile);
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());

FileInputStream fin = new FileInputStream(listFiles[i]);
while (true) {
int len =, 0, b.length);
if (len <= 0)
out.write(b, 0, len);
System.out.println("Jar File is created successfully.");
} catch (Exception ex) {}
public static void main(String[]args){
CreateExe exe=new CreateExe();
FilenameFilter ff = new OnlyExt("class");
File folder = new File("c:/Examples");
File[] files = folder.listFiles(ff);
File file=new File("C:/Examples/Examples.exe");
exe.create(file, files);