Java program file to an exe file
hi all
i am a final year student doing project in java environment. in my project i want to convert a java program to an exe file.. i have seen some of the replies from the forum but i am not clear with that..
i need the steps in detail and the way how to do...?
thanks in advance
If you Google, you will find a commercial Java compiler available for 60-day free trial. It provides detailed instructions on how to get started with compiling your code. The 60 days should be enough time for finishing your school work.
Similar Messages
-
Java Program- File & Directories
Hi, I was wondering if anyone can helpe me out with this program. I have a good start on it but keep on getting errors.
The task is to read one command line argument that contains the directory name. Using recursion, traverse the directory and all its sub-directories. Then for each file in each direcotry create an object class which keeps track of the file name (absolute path) and the size of the file, then adds the object to a Vector. Once thats done, i have to print a report showing each file name and size in decending order of file size. I have attached what i have so far... if ne one can help me i'll be verryyyyy greatfulll
for(i=0; i<fileList.size(); i++){
File file = (File)fileList.get(i);
System.out.print(file.getAbsolutePath());
System.out.println("Length of File: " + file.length());Hi,
First you have to recursive method to build your file List and then sort the list and print. You can get a good start from the following code:
public void buildFileList(File file, ArrayList list)
list.add(file);
if(file.isDirectory())
File[] files = file.listFiles();
for(int i=0; i < files.length; i++)
buildFileList(files, list);
public void printFiles(ArrayList list)
Comparator cmp = new Comparator()
public int compare(Object o1, Object o2)
if( ((File)o1).length() > ((File)o2).length() )
return -1;
else if( ((File)o1).length() < ((File)o2).length() )
return 1;
else
return 0;
Collections.sort(list);
for(int i=0; i < list.size(); i++)
System.out.println(((File)list.get(i)).getAbsolutePath()); -
How to compile and run a .java file from another java program
hello,
can any one tell me how to compile and run a *.java* file from another java program which is not in same directory?Well a smarter way of implementing this is by using a solution provided by Java Itself.
If you are using J2SE 6.0+ there is an in built solution provided along with JDK itself and inorder to go ahead with solution the below are set of API which you;d be using it for compiling Java Programs (Files)
http://java.sun.com/javase/6/docs/api/javax/tools/package-summary.html
How do i do that ??
Check out the below articles which would help you of how to do that
http://www.ibm.com/developerworks/java/library/j-jcomp/index.html
http://www.javabeat.net/javabeat/java6/articles/java_6_0_compiler_api_1.php
http://books.google.com/books?id=WVbpv8SQpkEC&pg=PA155&lpg=PA155&dq=%22javax+tools%22+compiling+java+file&source=web&ots=XOt0siYe-f&sig=HH27ovuwvJgklIf8omTykUmy-eM
Now once we are done with compilation.In order to run a Specific class all you ought to do is create an object and its specific methods of a specified class included in the CLASSPATH which you can manage it easily by usage little bit reflections.
Hope that might help :)
REGARDS,
RaHuL -
Unable to locate existing file from unix using java program
Hi
I have created a file in unix using java program, file.createNewFile();
And when i try to search for the same file using file.exists() it is returning false. Paths are correct. Can anybody help me out.
Thanks & Regards,
PrasanthIn Linux FC5 using JDK1.6, this code File temp = new File(System.getProperty("user.home") + "/abcdefghijklmn");
System.out.println(temp.createNewFile());prints 'true' and the file is created with length zero. -
How to execute a java program by clicking !?!?
Just a click to execute a java program?!!
Like the ".exe" in Windows or "x" permission in Unix ?!?!?!
How can I do that?
And how to set a java program file to display as a personal icon? (My Icon)
:-)Well this is what I do in Windows (I use XP but it works in others):
First you have to make sure all the class files are in the same folder (duh)
Then you copy your java.exe from your jre folder into the folder with all your class files.
Finally, you create a shortcut to java.exe and add your class name to the command line on the shortcut.
Now all you have to do is double click on the shortcut and your program runs. Sure it's not that pretty but it works. -
Running java program in other machines
i want to run my java program file in other machines , how i can do this without installing jdk1.3 on them?
install the JRE instead.
-
When i click on the icon to open Firefox an error message box appears with the following message, C:\Program Files\Java\jre6\lib\deploy\jqs\ff\..\..\..\..\bin\jqsnotify\.exe cannot be found. It then advises me to use the Search function, but the search function says it is unavailable.
What is it? and how do I fix it? in EnglishSee:
http://www.java.com/en/download/help/quickstarter.xml - What is Java Quick Starter (JQS)? What is the benefit of running JQS? - 6.0 -
How to run an exe file in a java program
Hi,
Can somebody tell me how to run an exe file in a java program.
Thank you!Yes, java.lang.Runtime.exec().
Read this carefully before you do:
http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html
Don't write a line of code before you're reviewed and understood the article completely. - MOD -
Calling a function in an EXE file from Java Program
Hi Im having a function which is written in c program.i need to call that function from my java program, if i create a shared library (DLL) for my C code then it works but my requirement is i dont want to create that DLL , like in it would be an executable and my java code should access that function in that C program
I understand the usage od a DLL but the thing is if i convert the exe to a DLL
the server doesnt start at all so what i need is that i dont want to change
that .EXE into a .DLL,let it be an executable. that executable is in running mode
and through my java program i need to call a function in that EXE file.
Is ther any way to do it?Nope, but you have another problem: why can't you separate your server program
into a .dll part and a startup part? Both, when properly linked against each other
should give you an executable file.
kind regards,
Jos -
Can we run EXE file/ Another Java Program from Java Application? How?
Can we run EXE file and another java program from java application?
Thanks in advanceExample running adobe acrobat
String command = "C:\\Program Files\\Adobe\\Acrobat 5.0\\Reader\\AcroRd32.exe /t "+selectedDocument+" \\\\CONTROL\\HP LaserJet 4L";
Runtime rn = Runtime.getRuntime();
Process process = rn.exec(command);
process.waitFor();rykk -
I have been having problems logging in and had to go to system set not quite knowing what I am doing I sent and changed to configure default, then when I went in my plugin crashed so I tried to update java again an got the above area message,Runtime error program c:/ program files\mozilla\firefox\firefox exe R6205 -pure virtual function call. I also tried to update my driver but as soon as they started checking updates mozilla shut down
Try checking this guide on [http://www.pcperformancetools.com/runtimeerrors.htm
runtime error download] It discusses step-by-step instructions on how to diagnose and repair windows runtime problems. They also got a free tool to clean-out and repair corrupt associations in the Windows Registry automatically. -
Need urgent help. Execution of .exe files by calling from java program
This program can execute small .exe files which donot take inputs. But does not work for exe files that take input and just hangs. What could be the problem. If anyone helps me I would be very grateful.
Server code :-
import java.io.*;
import java.net.*;
public class Server1 {
private Player[] players;
private ServerSocket server;
private ExecHelper exh;
String command = null;
String message = null;
public Server1() {
players = new Player[5];
try {
server = new ServerSocket( 12345, 5 );
System.out.println("Server started...");
System.out.println("Waiting for request...");
catch( IOException ioe ) {
ioe.printStackTrace();
System.exit( 1 );
} //end Server constructor
public void execute() {
for( int i = 0; i < players.length; i++ )
try {
players[i] = new Player( server.accept() );
players.start();
catch( IOException ioe ) {
ioe.printStackTrace();
System.exit( 1 );
public static void main( String args[] ) {
Server1 ser = new Server1();
ser.execute();
System.exit( 1 );
private class Player extends Thread {
private Socket connection;
private ObjectOutputStream output;
private ObjectInputStream input;
public Player( Socket socket ) {
connection = socket;
try {
input = new ObjectInputStream( connection.getInputStream());
output = new ObjectOutputStream( connection.getOutputStream());
output.flush();
catch( IOException ioe ) {
ioe.printStackTrace();
System.exit( 1 );
public void run() {
try {
message = "Enter a command:";
output.writeObject( message );
output.flush();
do {
command = ( String ) input.readObject();
String osName = System.getProperty( "os.name" );
String[] cmd = new String[3];
if( osName.equals( "Windows 2000" )) {
cmd[0] = "cmd.exe";
cmd[1] = "/c";
cmd[2] = command;
else if( osName.equals( "Windows NT" ) ) {
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = command ;
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec( cmd );
exh = new ExecHelper( proc, output, input);
} while( !command.equals( "TERMINATE" ) );
catch( Throwable t ) {
t.printStackTrace();
} //end class Player
public class ExecHelper implements Runnable {
private Process process;
private InputStream pErrorStream;
private InputStream pInputStream;
private OutputStream pOutputStream;
private InputStreamReader isr;
private InputStreamReader esr;
private PrintWriter outputWriter;
private ObjectOutputStream out;
private ObjectInputStream in;
private BufferedReader inBuffer;
private BufferedReader errBuffer;
private Thread processThread;
private Thread inReadThread;
private Thread errReadThread;
private Thread outWriteThread;
public ExecHelper( Process p, ObjectOutputStream output, ObjectInputStream input ) {
process = p;
pErrorStream = process.getErrorStream();
pInputStream = process.getInputStream();
pOutputStream = process.getOutputStream();
outputWriter = new PrintWriter( pOutputStream, true );
in = input;
out = output;
processThread = new Thread( this );
inReadThread = new Thread( this );
errReadThread = new Thread( this );
outWriteThread = new Thread( this );
processThread.start();
inReadThread.start();
errReadThread.start();
outWriteThread.start();
public void processEnded( int exitValue ) {
try {
Thread.sleep( 1000 );
catch( InterruptedException ie ) {
ie.printStackTrace();
public void processNewInput( String input ) {
try {
out.writeObject( "\n" + input );
out.flush();
catch( IOException ioe ) {
ioe.printStackTrace();
public void processNewError( String error ) {
try {
out.writeObject( "\n" + error );
out.flush();
catch( IOException ioe ) {
ioe.printStackTrace();
public void println( String output ) {
outputWriter.println( output + "\n" );
public void run() {
if( processThread == Thread.currentThread()) {
try {
processEnded( process.waitFor());
catch( InterruptedException ie ) {
ie.printStackTrace();
else if( inReadThread == Thread.currentThread() ) {
try {
isr = new InputStreamReader( pInputStream );
inBuffer = new BufferedReader( isr );
String line = null;
while(( line = inBuffer.readLine()) != null ) {
processNewInput( line );
catch( IOException ioe ) {
ioe.printStackTrace();
else if( outWriteThread == Thread.currentThread() ) {
try {
String nline = null;
nline = ( String ) in.readObject();
println( nline );
catch( ClassNotFoundException cnfe ) {
// cnfe.printStackTrace();
catch( IOException ioe ) {
ioe.printStackTrace();
else if( errReadThread == Thread.currentThread() ) {
try {
esr = new InputStreamReader( pErrorStream );
errBuffer = new BufferedReader( esr );
String nline = null;
while(( nline = errBuffer.readLine()) != null ) {
processNewError( nline );
catch( IOException ioe ) {
ioe.printStackTrace();
Client code :-
// client.java
import java.io.*;
import java.net.*;
public class Client {
private ObjectOutputStream output;
private ObjectInputStream input;
private String chatServer;
private String message = "";
private Socket client;
public Client( String host ) {
chatServer = host;
private void runClient() {
try {
connectToServer();
getStreams();
processConnection();
catch( EOFException eofe ) {
System.err.println( "Client terminated connection ");
catch( IOException ioe ) {
ioe.printStackTrace();
finally {
closeConnection();
} //end method runClient
private void connectToServer() throws IOException {
System.out.println( "Attempting connection...\n");
client = new Socket( InetAddress.getByName( chatServer ), 12345);
System.out.println( "Connected to : "+ client.getInetAddress().getHostName());
private void getStreams() throws IOException {
output = new ObjectOutputStream( client.getOutputStream());
output.flush();
input = new ObjectInputStream( client.getInputStream());
private void processConnection() throws IOException {
while( true ){
try {
message = ( String ) input.readObject();
System.out.print( message );
InputStreamReader isr = new InputStreamReader( System.in);
BufferedReader br = new BufferedReader( isr );
String line = null ;
line = br.readLine();
output.writeObject(line);
output.flush();
catch( ClassNotFoundException cnfe) {
System.out.println( "\nUnknown object type received");
} //end processConnection
private void closeConnection() {
System.out.println( "\nClosing connection");
try {
output.close();
input.close();
client.close();
catch( IOException ioe ) {
ioe.printStackTrace();
public static void main( String args[] ) {
Client c;
if( args.length == 0 )
c = new Client( "127.0.0.1" );
else
c = new Client( args[0] );
c.runClient();pay close attention to the comments in this thread
http://forum.java.sun.com/thread.jspa?threadID=769142&messageID=4383764#4383764 -
Need urgent help. Calling of exe files from java program
This program can execute small .exe files that donot take inputs but doesn't work for exe files that takes input. what could be the problem.
Server code :-
import java.io.*;
import java.net.*;
public class Server1 {
private Player[] players;
private ServerSocket server;
private ExecHelper exh;
String command = null;
String message = null;
public Server1() {
players = new Player[5];
try {
server = new ServerSocket( 12345, 5 );
System.out.println("Server started...");
System.out.println("Waiting for request...");
catch( IOException ioe ) {
ioe.printStackTrace();
System.exit( 1 );
} //end Server constructor
public void execute() {
for( int i = 0; i < players.length; i++ )
try {
players[i] = new Player( server.accept() );
players.start();
catch( IOException ioe ) {
ioe.printStackTrace();
System.exit( 1 );
public static void main( String args[] ) {
Server1 ser = new Server1();
ser.execute();
System.exit( 1 );
private class Player extends Thread {
private Socket connection;
private ObjectOutputStream output;
private ObjectInputStream input;
public Player( Socket socket ) {
connection = socket;
try {
input = new ObjectInputStream( connection.getInputStream());
output = new ObjectOutputStream( connection.getOutputStream());
output.flush();
catch( IOException ioe ) {
ioe.printStackTrace();
System.exit( 1 );
public void run() {
try {
message = "Enter a command:";
output.writeObject( message );
output.flush();
do {
command = ( String ) input.readObject();
String osName = System.getProperty( "os.name" );
String[] cmd = new String[3];
if( osName.equals( "Windows 2000" )) {
cmd[0] = "cmd.exe";
cmd[1] = "/c";
cmd[2] = command;
else if( osName.equals( "Windows NT" ) ) {
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = command ;
Runtime rt = Runtime.getRuntime();
Process proc = rt.exec( cmd );
exh = new ExecHelper( proc, output, input);
} while( !command.equals( "TERMINATE" ) );
catch( Throwable t ) {
t.printStackTrace();
} //end class Player
public class ExecHelper implements Runnable {
private Process process;
private InputStream pErrorStream;
private InputStream pInputStream;
private OutputStream pOutputStream;
private InputStreamReader isr;
private InputStreamReader esr;
private PrintWriter outputWriter;
private ObjectOutputStream out;
private ObjectInputStream in;
private BufferedReader inBuffer;
private BufferedReader errBuffer;
private Thread processThread;
private Thread inReadThread;
private Thread errReadThread;
private Thread outWriteThread;
public ExecHelper( Process p, ObjectOutputStream output, ObjectInputStream input ) {
process = p;
pErrorStream = process.getErrorStream();
pInputStream = process.getInputStream();
pOutputStream = process.getOutputStream();
outputWriter = new PrintWriter( pOutputStream, true );
in = input;
out = output;
processThread = new Thread( this );
inReadThread = new Thread( this );
errReadThread = new Thread( this );
outWriteThread = new Thread( this );
processThread.start();
inReadThread.start();
errReadThread.start();
outWriteThread.start();
public void processEnded( int exitValue ) {
try {
Thread.sleep( 1000 );
catch( InterruptedException ie ) {
ie.printStackTrace();
public void processNewInput( String input ) {
try {
out.writeObject( "\n" + input );
out.flush();
catch( IOException ioe ) {
ioe.printStackTrace();
public void processNewError( String error ) {
try {
out.writeObject( "\n" + error );
out.flush();
catch( IOException ioe ) {
ioe.printStackTrace();
public void println( String output ) {
outputWriter.println( output + "\n" );
public void run() {
if( processThread == Thread.currentThread()) {
try {
processEnded( process.waitFor());
catch( InterruptedException ie ) {
ie.printStackTrace();
else if( inReadThread == Thread.currentThread() ) {
try {
isr = new InputStreamReader( pInputStream );
inBuffer = new BufferedReader( isr );
String line = null;
while(( line = inBuffer.readLine()) != null ) {
processNewInput( line );
catch( IOException ioe ) {
ioe.printStackTrace();
else if( outWriteThread == Thread.currentThread() ) {
try {
String nline = null;
nline = ( String ) in.readObject();
println( nline );
catch( ClassNotFoundException cnfe ) {
// cnfe.printStackTrace();
catch( IOException ioe ) {
ioe.printStackTrace();
else if( errReadThread == Thread.currentThread() ) {
try {
esr = new InputStreamReader( pErrorStream );
errBuffer = new BufferedReader( esr );
String nline = null;
while(( nline = errBuffer.readLine()) != null ) {
processNewError( nline );
catch( IOException ioe ) {
ioe.printStackTrace();
Client code :-
// client.java
import java.io.*;
import java.net.*;
public class Client {
private ObjectOutputStream output;
private ObjectInputStream input;
private String chatServer;
private String message = "";
private Socket client;
public Client( String host ) {
chatServer = host;
private void runClient() {
try {
connectToServer();
getStreams();
processConnection();
catch( EOFException eofe ) {
System.err.println( "Client terminated connection ");
catch( IOException ioe ) {
ioe.printStackTrace();
finally {
closeConnection();
} //end method runClient
private void connectToServer() throws IOException {
System.out.println( "Attempting connection...\n");
client = new Socket( InetAddress.getByName( chatServer ), 12345);
System.out.println( "Connected to : "+ client.getInetAddress().getHostName());
private void getStreams() throws IOException {
output = new ObjectOutputStream( client.getOutputStream());
output.flush();
input = new ObjectInputStream( client.getInputStream());
private void processConnection() throws IOException {
while( true ){
try {
message = ( String ) input.readObject();
System.out.print( message );
InputStreamReader isr = new InputStreamReader( System.in);
BufferedReader br = new BufferedReader( isr );
String line = null ;
line = br.readLine();
output.writeObject(line);
output.flush();
catch( ClassNotFoundException cnfe) {
System.out.println( "\nUnknown object type received");
} //end processConnection
private void closeConnection() {
System.out.println( "\nClosing connection");
try {
output.close();
input.close();
client.close();
catch( IOException ioe ) {
ioe.printStackTrace();
public static void main( String args[] ) {
Client c;
if( args.length == 0 )
c = new Client( "127.0.0.1" );
else
c = new Client( args[0] );
c.runClient();maybe you should
1. Use code tags so the posted code is understandable
2. Stop marking your post urgent, that just puts peoples backs up
3. Stop posting the question every couple of hours on every imaginable forum.. Post it once and start a single dialog -
Invoking exe file through java program
I have one exe file,which i want to invoke it from java program.I have used Runtime class to execute the exe, but it throws an exception
java.io.IOException: CreateProcess: afp2web.exe -q -PDF -c -fm samples\medform.a
fp error=2
at java.lang.Win32Process.create(Native Method)
at java.lang.Win32Process.<init>(Unknown Source)
at java.lang.Runtime.execInternal(Native Method)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at java.lang.Runtime.exec(Unknown Source)
at Afp2PdfDemo.main(Afp2PdfDemo.java:7)
However if i give the absolute path of exe file then it doesn't throw an exception but at the same time,it doesn't the do the expected job.
Can somebody throw some light on this?
Thanx in advance
Regards,
PulakHave you tried also supplying the absolute paths of the file arguments like "samples\medform.a"?
-
How to make Exe file of java program
how we can make the exe file of java programs. that can run independently of particuler JVM. like in VB we can create exe files.
- early thanksCheck this out:
http://search.java.sun.com/search/java/index.jsp?qp=%2B
orum%3A31&nh=10&qt=create+exe+file+program&col=javaforu
s
Maybe you are looking for
-
Hi all, We have CUA (release 7.00) that is not working with older release clients. I implemented 2 release 7.00 clients to CUA; they both work fine. However, when I implement some older release clients (like, 4.5B, 4.6C, 6.20 and 6.40) to CUA, I can
-
JAX-WS client - WebLogic - SSL with proxy server
Good night! I'm having trouble communicating with webservices using certificate authentication (weblogic.wsee.jaxws.sslclient.PersistentSSLInfo) through and going through a proxy server (weblogic.wsee.jaxws.proxy.ClientProxyFeature) . If communicatio
-
Compaibility with Panasonic PV-DV203
Is there any compatibility? When I connect using USB nothing happens. Nothing on the site either.
-
Why won't certain texts go through?
I have one number in my contact list that keeps getting the red exclamation mark every time I text it. They used to go through and now they don't. Anyone know why?
-
Hello, I have the router attached to my bigpond cable modem, the linksys router periodically drops connections to all Wired and wireless connections and then reconnects, this is incredibly annoying and could not find any way to explain this other tha