User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 429,971 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,565 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 37603 | Replies: 7
Reply
Join Date: Jun 2004
Posts: 604
Reputation: freesoft_2000 is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 6
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Help How to run external .exe programs from java

  #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
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Jul 2004
Posts: 4
Reputation: BlackDeath is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
BlackDeath's Avatar
BlackDeath BlackDeath is offline Offline
Newbie Poster

Re: How to run external .exe programs from java

  #2  
Jul 2nd, 2004
the code goes like this:
try
{
 Runtime rt = Rintime.getRuntime() ;
 Process p = rt.exec("Program.exe") ;
 InputStream in = p.getInputStream() ;
 OutputStream out = p.getOutputStream ();
 InputSream err = p,getErrorStram() ;
 
//do whatever you want
 //some more code
 
 p.destroy() ;
}catch(Exception exc){/*handle exception*/}
It's not wrong not knowing, but it's wrong not wanting to know.
Reply With Quote  
Join Date: Jul 2004
Location: Pakistan
Posts: 1,673
Reputation: nanosani is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 50
Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: How to run external .exe programs from java

  #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  
Join Date: Jun 2004
Posts: 604
Reputation: freesoft_2000 is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 6
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: How to run external .exe programs from java

  #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 3:30 am. Reason: removed email address
Reply With Quote  
Join Date: Jul 2004
Location: Pakistan
Posts: 1,673
Reputation: nanosani is an unknown quantity at this point 
Rep Power: 8
Solved Threads: 50
Colleague
nanosani's Avatar
nanosani nanosani is offline Offline
Unauthenticated Liar

Re: How to run external .exe programs from java

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

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

Re: How to run external .exe programs from java

  #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...

try
   {
    Runtime rt = Runtime.getRuntime();
    Process p = rt.exec("vbex.exe");
    InputStream in = p.getInputStream();
    OutputStream out = p.getOutputStream();
    InputStream err = p.getErrorStream();

    p.destroy() ;
    }catch(Exception exc){/*handle exception*/}
Reply With Quote  
Join Date: Jun 2004
Posts: 604
Reputation: freesoft_2000 is an unknown quantity at this point 
Rep Power: 6
Solved Threads: 6
freesoft_2000 freesoft_2000 is offline Offline
Practically a Master Poster

Re: How to run external .exe programs from java

  #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  
Join Date: Jun 2008
Posts: 3
Reputation: subroto1486 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
subroto1486 subroto1486 is offline Offline
Newbie Poster

Re: How to run external .exe programs from java

  #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  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 11:53 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC