public class DataAcc { public Connection con=null; public Connection getConnect() { try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); con=DriverManager.getConnection("jdbc:odbc:msdesktop"); System.out.println("Connected"); } catch(Exception e) { System.out.println(e); } return con; }//getConnection
}//class
the program works successfully.
my problem is "the total application is converted into the setup file".
how can u convert the desktop application into setup file .
please help me.
the Answers is
Try the following code:
import java.io.*; import java.util.jar.*;
public class CreateExe { public static int buffer = 10240; protected void createExeArchive(File jarFile, File f) { try { byte b[] = new byte[buffer]; FileOutputStream fout = new FileOutputStream(jarFile); JarOutputStream out = new JarOutputStream(fout, new Manifest());
if (f == null || !f.exists()|| f.isDirectory()) System.out.println(); JarEntry addFile = new JarEntry(f.getName()); addFile.setTime(f.lastModified()); out.putNextEntry(addFile);
FileInputStream fin = new FileInputStream(f); 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 jar=new CreateExe(); File f = new File("C:/LoginDemo.java"); File file=new File("C:/LoginDemo.exe "); jar.createExeArchive(file, f); }
}
how this is compile and run and where the setup file is created can u tell me please.
View Answers
July 28, 2010 at 4:54 PM
Hi Friend,
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(); 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/Examples"); File[] files = folder.listFiles();
Put the path of directory in which you have created java files, into the following code:
File folder = new File("-----here-----");
The above code will compile and run same as other java files and create your set up file in the c drive with the name Application.jar
Thanks
Related Pages:
Setup file - Java Beginners Setup file Hello sir ,how i can make Java Programs Set up File.... Point to note here is that the Java compiler very well knows about...:
http://www.roseindia.net/java/exceptions/how-to-throw-exceptions.shtml
java setup - Java Beginners java setup Hi,
Iam created a desktop
login application using swings.
pls observe the following code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class LoginDemo{
JButton
java setup - Java Beginners java setup Hi,
Iam created a desktop
login application using swings.
pls observe the following code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
class LoginDemo{
JButton
installation and setup problem - Java Beginners
installation and setup problem Hi,
Iam new to java.Can any one tell me about how to install tomcat5.5 and set up in my windows xp operating system in detail?
Thanks in advance
Creating a setup file
Creating a setup file How to create a setup file in tomcat as done in visual studio... could plz tell me as early as possible
Hibernate Relationships - Settingup database
- Setting up database:
In this section we will setup the database... setup the database and create the MySQL schema. We will use
the Hibernate... OneToManyRelation.java
in the Eclipse and right click and select Run As--> Java application
Setup MySQL Database Setup MySQL Database
In this section we will create database and table into
MySQL database. Table created here will be used in sample application
SUSE Linux 10.1 Beta9
;Update Configuration" to setup your
system for Online Updates and get... release notes fails due to a RPM signature
check.
Registration setup...
such as Adobe Acrobat Reader, RealNetworks RealPlayer, Sun Java Runtime
Writing Hibernate Configuration Files
the database setup and created required
table and populated with the data... in the source directory e.g. "C:\Struts-Hibernate-Integration\code\src\java... of Java Bean object (Tutorial.java) used to store and retrieve
the data from
Writing Hibernate Configuration Files
the database setup and created required
table and populated with the data. In this section...-Integration\code\src\java\roseindia\net\dao\hibernate\"
POJO Object
Here is the code of Java Bean object (Tutorial.java) used to store
Developing Simple Struts Tiles Application
how to setup the Struts Tiles and create example
page with it.
What is Struts... language="java" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix... language="java" %>
<%@ taglib uri="/WEB-INF/struts-tiles.tld
Downloading Struts & Hibernate
Downloading Struts & Hibernate
In this we will download Struts & Hibernate and setup the development
environment.
Downloading Hibernate
Hibernate is free
Damn Small Linux 2.3 RC1 has been released now
Damn Small Linux 2.3 RC1 has been released now
New check and prompt to save APSFILTER printer setup; new check and prompt to save wireless setup; new MyDSL is now a separate menu via a Fluxbox [include]; new prompt when keyboard
java
java Hell Team,
I am totally new to java, from net am setup in my machine netbeans, mysql and tomcat server. I am working in a small enterprise where 50-60 desktops are there, I want to create a web application where I can put
To make java exe or runnable file
To make java exe or runnable file Helo sir
i make a java application.I need to help how run application direct in pc i.e how it packaged, .exe file or setup file
java code - Development process java code to setup echo server and echo client. Hi Friend,
Please visit the following links:
http://www.roseindia.net/java/network/
http://www.roseindia.net/java/example/java/net/udp/
Hope
qunit jquery with java script
qunit jquery with java script hi deepak
How to write a javascript code and do the test by using qunit sample application
and as I am new to testing how to setup the environment for java script testing? where should I run
Core java
Core java How to use hyperlink that is href tag in core java without swing, frames etc.
My code is
StringBuffer oBodyStringBuffer = new...");
oBodyStringBuffer.append("\n\n");
The mail is setup is done here and its converted
Dyna Trace
Dyna Trace
dynaTrace Diagnostics CodeLink is an extension for
eclipse, so in order to use it you would need to download and setup eclipse on
your machine. Please check
java mail java mail Hi deepak,
sorry to trouble again but with reference to apache mail server (james)
tutorial i use the link... where and some one have copied those and zipped.so where is setup of james
Tomcat5.5 - Java Beginners
Tomcat5.5 how to setup and run tomcat 5.5 in windows xp? to set up tomcat ...jus u have to do 2 steps
1.set ur java_home
2. set ur catlina_home
it means specifying java and tomcat bin directory path
java compilation error - Java Beginners java compilation error Hello,
I had recently sent an email..._number_of_supplies);
//setup the GUI
//add the next office supply button to the top of the GUI
// setup a panel to collect all the buttons
java compilation error - Hibernate java compilation error hi, i have made an registration page whosevalues should be inserted into database. i have used hibernate and eclipse... the corresponding database in the sql(of course u should install your sql setup
Java SFTP - Java Beginners Java SFTP Hi I want to perform SFTP through Jsch package. I could able to sftp one file but I could not able to sftp multiple files.
PFB my... com.sun.crypto.provider.SunJCE());
//
//Setup Strict
Struts Interview Questions
Struts Interview Questions
Question: Can I setup Apache Struts to use
multiple configuration files?
Answer: Yes Struts can use multiple configuration files. Here
java mail java mail import javax.mail.*;
import javax.mail.internet....)
throws MessagingException, AddressException
{
// Setup mail...:
Java Mail
Thanks
How to run java swing application from jar files .
How to run java swing application from jar files . Hello Sir,
I developed a java swing application .Now i want to execute it as .exe setup file .As per my knowledge i have to run .jar file from dist folder
POI3.0 - Java Beginners
POI3.0 Please send me the environment setup to run these type of example.
where i gotthese file? i think we need poi3.0.jar.How & where i got it?
import org.apache.poi.hssf.usermodel.*;
import
java awt package tutorial Java AWT Package
In Java, Abstract Window Toolkit(AWT) is a platform independent
widget toolkit for windowing, graphics, and user-interface.
As the Java..., the buttons work as Microsoft Windows buttons when we run a
Java application
Java Mail
to the original sender.
SetupJava 2 Platform, Enterprise Edition (J2EE) 1.3,
includes JavaMail, therefore no additional setup is required, while...
Java Mail
 
Installing Java
. stand alone applications can be made in java by using
JDK. Windows 95/NT setup...
Installing Java
 .... The
combination of two features Platform Independent and Object Oriented makes the
java
how to create a set up file of java web application
how to create a set up file of java web application I have already developed a java web application using struts 2.x, jsp,tomcat server, oracle... to my client, so in this case I would like to make my product as a setup file,where
how to create a set up file of java web application
how to create a set up file of java web application I have already developed a java web application using struts 2.x, jsp, oracle as a back end data... in this case I would like to make my product as a setup file,where my client can
how to create a set up file of java web application
how to create a set up file of java web application I have already developed a java web application using struts 2.x, jsp, oracle as a back end data... in this case I would like to make my product as a setup file,where my client can
Free Java Shopping Cart,Shopping cart Application
Free Java Shopping Cart application and setup your online store. Shopping cart...
Free Java Shopping Cart
Shopping Cart allows the web site owner to setup online store so that visitors can
error in program when trying to load image in java - Java Beginners
to add an image to my GUI using java graphics. I have cleaned up all my compiler..." and add the logo to the GUI using Java graphics.
this is the main codes... to obtain the image.
// setup the GUI logo
URL url = this.getClass