How to convert many class files into one exe file?

Ads
 

How to convert many class files into one exe file?

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 2:01 PM

Hi Friend,

Happy Pongal!!!!!!

Try the following code:

import java.io.*;
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());
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){
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);
}

}

Thanks


January 14, 2011 at 2:01 PM

Hi Friend,

Happy Pongal!!!!!!

Try the following code:

import java.io.*;
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());
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){
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);
}

}

Thanks


January 16, 2011 at 9:04 AM

sorry friend, i can't understand it. can u explain the code?

Ads









Related Tutorials/Questions & Answers:
How to convert many class files into one exe file?
How to convert many class files into one exe file?
Advertisements
invoking exe files on sound
How to copy many files into one file and how to manage the content of the final file?
How to Convert Text Files into Gzip File
How do I decompile Java class files?
How can I Convert my Image Files to Text Files? - IDE Questions
How to convert multiple files in java to .zip format
how to convert jsp to exe
compiling .class files
how to convert war file into .exe file using java code
how to convert a jar file into .exe file
files
How to copy files from one folder to another based on lastmodified date - Java Beginners
files
files
files
files
files
files
Class files for Jfreechart - JSP-Servlet
How to list files in hadoop?
How to copy files from one folder to another based on lastmodified date - Java Beginners
Using several configuration resource files in one single application
help me plz:-Merge multiple jasper files into Single one
How Compare 2 xml files with JDOM - Java Beginners
how to backup files and folder with Java
how to read the values for text and csv files and store those values into database in multiple rows..means one value for one row
How to upload files to server using JSP/Servlet?
How To Write the FORM Tag Correctly for Uploading Files?
how to creating hbm files in hibernate using Myeclipse

Ads