How to run external .exe programs from java

Reply

Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

How to run external .exe programs from java

 
0
  #1
Jul 2nd, 2004
Hi everyone,

Could some one please tell me or show me the entire codings of how to run external .exe programs in java. I want to do this because i have a lot c/vb programs that i want to run in my java program.

Thank You

Yours Sincerely

Richard West
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 4
Reputation: BlackDeath is an unknown quantity at this point 
Solved Threads: 0
BlackDeath's Avatar
BlackDeath BlackDeath is offline Offline
Newbie Poster

Re: How to run external .exe programs from java

 
0
  #2
Jul 2nd, 2004
the code goes like this:
  1. try
  2. {
  3. Runtime rt = Rintime.getRuntime() ;
  4. Process p = rt.exec("Program.exe") ;
  5. InputStream in = p.getInputStream() ;
  6. OutputStream out = p.getOutputStream ();
  7. InputSream err = p,getErrorStram() ;
  8.  
  9. //do whatever you want
  10. //some more code
  11.  
  12. p.destroy() ;
  13. }catch(Exception exc){/*handle exception*/}
It's not wrong not knowing, but it's wrong not wanting to know.
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 54
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: How to run external .exe programs from java

 
0
  #3
Jul 15th, 2004
try out this code ... it will not be platform independent ....
Process p = Runtime.getRuntime().exec("c:\myprogram.exe");

I dont have the time to test it .... if you succeed please tell me too.
:eek:
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: How to run external .exe programs from java

 
0
  #4
Aug 28th, 2004
Hi everyone,
The above codes only seem to run external .exe programs but what if i want to run external jar programs. Could someone show me or e-mail me the codings of how to do this the right way.


Thank You

Yours Sincerely

Richard West
Last edited by alc6379; Oct 23rd, 2004 at 4:30 am. Reason: removed email address
Reply With Quote Quick reply to this message  
Join Date: Jul 2004
Posts: 1,749
Reputation: nanosani is an unknown quantity at this point 
Solved Threads: 54
Team Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: How to run external .exe programs from java

 
0
  #5
Aug 29th, 2004
Read about the dynamic class loader

http://java.sun.com/j2se/1.4.2/docs...lassLoader.html
Reply With Quote Quick reply to this message  
Join Date: Oct 2004
Posts: 1
Reputation: ozzytx is an unknown quantity at this point 
Solved Threads: 0
ozzytx ozzytx is offline Offline
Newbie Poster

Re: How to run external .exe programs from java

 
0
  #6
Oct 19th, 2004
i'm using the code from above to try to run a program and here's my problem... when i call an exe that i wrote in VB, the program runs fine. if i call a c or c++ program the program loads into memory (i see it in the processes tab) but the console doesn't open up with the program in it.
here's the code i have right now for it...

  1. try
  2. {
  3. Runtime rt = Runtime.getRuntime();
  4. Process p = rt.exec("vbex.exe");
  5. InputStream in = p.getInputStream();
  6. OutputStream out = p.getOutputStream();
  7. InputStream err = p.getErrorStream();
  8.  
  9. p.destroy() ;
  10. }catch(Exception exc){/*handle exception*/}
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 609
Reputation: freesoft_2000 is an unknown quantity at this point 
Solved Threads: 7
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: How to run external .exe programs from java

 
0
  #7
Oct 19th, 2004
hi everyone,

Do this instead

void run ()
{
try
{
Runtime rt = Runtime.getRuntime();
Process p = rt.exec("vbex.exe");
}

catch(Exception e)
{

}

}

I hope this helps you

Richard West
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 3
Reputation: subroto1486 is an unknown quantity at this point 
Solved Threads: 0
subroto1486 subroto1486 is offline Offline
Newbie Poster

Re: How to run external .exe programs from java

 
0
  #8
Jun 16th, 2008
HI EVERYBODY,
I have a question regarding this i used this to call exe application but it is opening independently, but what if i want to run that particular exe in the frame itsself like an JInternal Frame..

Please help me regaridng this..

Thanks in advance..

Subroto Bhattacharjee
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC