how to create executable

how to create executable

How do i create a executable file from a java file
thnks in adv...!
View Answers

July 31, 2010 at 11:17 AM

Hi Friend,

Try the following code:

import java.io.*;
import java.util.jar.*;

public class CreateExe {
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();
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 ex=new CreateJar();
File folder = new File("C:/Answers/Examples");
File[] files = folder.listFiles();

File file=new File("C:/Answers/Examples/Examples.exe ");
ex.createJarArchive(file, files);
}

}

Thanks









Related Tutorials/Questions & Answers:
how to create executable - Java Beginners
how to create executable  How do i create a executable file from a java file thnks in adv...!  Hi Friend, Try the following code: import java.io.*; import java.util.jar.*; public class CreateExe { public
How to embed an executable plugin in my website?
How to embed an executable plugin in my website?  I want to embed an executable plugin in my website that will return client's Mac address run time. I am working with jsp/servlet. Please Help
Advertisements
How To Make Executable Jar File For Java P{roject - Java Beginners
How To Make Executable Jar File For Java P{roject   Hello Sir I want Help to make Executable File for java Project How I can Make it?  Hi Friend, Try the following code: import java.io.*; import java.util.jar.
ModuleNotFoundError: No module named 'act_as_executable'
named 'act_as_executable' How to remove the ModuleNotFoundError: No module named 'act_as_executable' error? Thanks   Hi, In your...ModuleNotFoundError: No module named 'act_as_executable'  Hi, My
ModuleNotFoundError: No module named 'executable-file'
named 'executable-file' How to remove the ModuleNotFoundError: No module named 'executable-file' error? Thanks   Hi, In your python...ModuleNotFoundError: No module named 'executable-file'  Hi, My
conversion of war file into executable jar file
conversion of war file into executable jar file  how to convert war file into executable jar file
Creating an executable jar file
Creating 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
Changing Executable Jar File Icon
;Hi, You may use JSmooth to create executable java file and also associate icon...Changing 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
How to create a jar file
How to create a jar file  Hello!!!! I have a project which has a multiple classes with database connection(MS-Access) & now i want to make a single executable jar of it... so pls tell me how it will b possible for me
Maven Repository/Dependency: com.mycodefu | executable-jar-archetype
? How to create Maven Web Application in Eclipse? Maven 3 Tutorial...Maven Repository/Dependency of Group ID com.mycodefu and Artifact ID executable-jar-archetype. Latest version of com.mycodefu:executable-jar-archetype
How to create an input box?
How to create an input box?  How to create an input box
How to create arrays in JavaScript?
How to create arrays in JavaScript?  How to create arrays in JavaScript
How to create a confirmation box?
How to create a confirmation box?  How to create a confirmation box
how to create frame in swings
how to create frame in swings  how to create frame in swings
how to create notepad in java
how to create notepad in java  how to create notepad in java
how to create session for login
how to create session for login  how to create session for login? how to display uploaded resume and images in the profile
How to create a class in java
How to create a class in java  I am a beginner in programming and tried to learn how to do programming in Java. Friends please explain how can I create a class in Java
How to create form in Swings
How to create form in Swings  How to create registration, login and question form in Java Swing?   Creating different forms in Java Swing - Examples how to create registration form in swing swing login form example
how to create web aplli
how to create web aplli  how to Create a web application using any technology to display 10 most relevant tweets from Twitter in real-time for the keyword "@cldmgc
how to create web aplli
how to create web aplli  how to Create a web application using any technology to display 10 most relevant tweets from Twitter in real-time for the keyword "@cldmgc
how to create a queue - JMS
how to create a queue  Can u please tell me how to create q queue in JMS and also tell me how to write a program to Send a Static Message for JMS Queue ....please i need it urgently
How to Create Keyboard in JAVA
How to Create Keyboard in JAVA  please help me to create On-Screen Keyboard with java and please give me an another idia to make it ..............iam waiting for your help ,think u so much
how to create ipa file
how to create ipa file  Hi, How to .ipa file? Thanks   Hi, Please check the thread Resources have been modified iPhone. Thanks
how to create rdd in pyspark
how to create rdd in pyspark  Hi, I am have to create an RDD from a String in PySpark. How to do this? How to create rdd in pyspark?   Hi, Its easy you can use the following code example: data = sc.parallelize(list
how to create a table
how to create a table  create table tablename (name varchar(10),name.... Use the following query: create table tablename (name varchar(10),address varchar(10)); For more information, visit the following link: Java Create
how to create uiwebview programmatically
how to create uiwebview programmatically  How to create uiwebview programmatically in iPhone application?   Given is the code that will create the WebView programmatically in iPhone.. CGRect webFrame = CGRectMake(0.0
How To Create a Table.
How To Create a Table.  How To Create a Table?   Hi friends, If you want to create a table, you can run the CREATE TABLE statement..._config.php"; $sql = "CREATE TABLE user_info(" . " id INTEGER NOT NULL" . ", name
How to create charts in Java?
How to create charts in Java?  Is there any example of creating charts and graphs in Java? thanks   Hi, check the tutorial: Chart & Graphs Tutorials in Java Thanks
how to create array in r
how to create array in r  Hi, In R Programming how array is created? how to create array in r? Explain me the process of array creation using.... You can create an array with the help of array keyword. Following is an example
How to create options in HTML
How to create options in HTML  How to create options in HTML? Please guide me.   Create options in HTML Code <tr> <td width="30" valign="middle">Gender:</td> <td><select
How to create variable in TensorFlow?
How to create variable in TensorFlow?  Hi, How to create variable... variable, you have to create the TensorFlow variable to use it with TensorFlow graph. Then tf.variable() method is used to create variable in TensorFlow
how to create array in python
how to create array in python  Hi, how to create array in python? I want to create an array in Python and add some values to it. Thanks   Hi, You can create a new array with the code myArray = [] and after
how to create vector in r
how to create vector in r  Hi, What is vector in R programming and how to create vector in r? Provide me some of the example code. Thanks   Hi, Vector in R is created using the key c(). Vector contains data of only
how to create interfaces in java
how to create interfaces in java  HI, Here is my code public interface validateInfo { public void validate(String empcode, String password); } class updateInfo implements validateInfo { public void update() { //code
how to create servlet
how to create servlet   package com.controller; import... if(request.getParameter("page").equalsIgnoreCase("create...(Exception e) { System.out.println("Error in controller create
how to create dao
how to create dao   code1: package com.dao; import java.sql.*; import com.beans.*; public class DbAccess { public void createStudent(SampleBean...) { System.out.println("Error in create access"); } } public SampleBean
how to create using jsp
how to create using jsp  code 1: <%@ page language="java...; <title>Create New Student</title> </head> <body> <form name="create" method="post" action="<
how to create a xml page
how to create a xml page  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <
PHP is_executable() Function and example
Syntax bool is_executable(file_name) Find the PHP is_executable() function states whether the given file is executable or not ADS_TO_REPLACE_1 Example of PHP is_executable Fu Code <?php    
Understanding Various MySQL Executable Files
Understanding Various MySQL Executable Files       This lesson you learn  how to the execute mysql file. MySQL  Provide the  executable file and uses
ModuleNotFoundError: No module named 'pip-executable-flag-bug-demo'
: No module named 'pip-executable-flag-bug-demo' How to remove the ModuleNotFoundError: No module named 'pip-executable-flag-bug-demo' error...ModuleNotFoundError: No module named 'pip-executable-flag-bug-demo'  
Version of com.mycodefu>executable-jar-archetype dependency
List of Version of com.mycodefu>executable-jar-archetype dependency
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for executable-jar-archetype version 1.0
Maven, Gradle, SBT, Ivy, Grape, Leiningen and Buildr Dependency for executable... com.mycodefu:executable-jar-archetype:1.0 Java library in your project.. Maven, Gradle, SBT, Ivy, Grape, Leiningen and  Buildr Dependency for executable
How to create Link in SWT
How to create Link in SWT       In this section, you will study how to create Link in a text. SWT allows to create link by using the class Link of package
how to create web page on jsp?
how to create web page on jsp?  how to create web page on jsp
how to create reports in swing java?
how to create reports in swing java?  how to create reports in swing java
How to Create Dynamic URLs in PHP?
How to Create Dynamic URLs in PHP?  How to Create Dynamic URLs in PHP
How to create dynamic array in C?
How to create dynamic array in C?  How to create dynamic array in c programming language?   Dynamic Array in C Tutorial
How to Create Instance using PHP
How to Create Instance using PHP  Hi, How to create an instance class in PHP program. Can someone explain or suggest any online reference how to create an Instance class in PHP. Thanks, (adsbygoogle
How to Create Segment Application with iPhone
How to Create Segment Application with iPhone  Hi, i am fresher in iphone application. How can i will create segment application in iphone. So, kindly help me or provide online example reference. Thanks

Ads