Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners how to create executable
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


raman
how to create executable
1 Answer(s)      4 years and 2 months ago
Posted in : Java Beginners


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

Advertisement
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.
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
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
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
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
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 Example of PHP is_executable Fu Code <?php     if (is_executable("c
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
how to create notepad in java
how to create notepad in java  how to create notepad in java
how to create frame in swings
how to create frame in swings  how to create frame in swings
How to create arrays in JavaScript?
How to create arrays in JavaScript?  How to create arrays in JavaScript
How to create an input box?
How to create an input box?  How to create an input box
How to create a confirmation box?
How to create a confirmation box?  How to create a confirmation box
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 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 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 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 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 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 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="<
Advertisements
 

 

 

DMCA.com