Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack (3) Thread Tools Display Modes
  3 links from elsewhere to this Post. Click to view. #1 (permalink)  
Old 10-04-2007, 10:33 PM
JavaBean's Avatar
Moderator
 
Join Date: May 2007
Posts: 1,272
JavaBean is on a distinguished road
How to execute an External Program through Java program
This example program will execute the external commands and capture the output.

Code:
import java.io.*; public class CommandExection { public CommandExection(String commandline) { try { String line; Process p = Runtime.getRuntime().exec(commandline); BufferedReader input = new BufferedReader (new InputStreamReader(p.getInputStream())); while ((line = input.readLine()) != null) { System.out.println(line); } input.close(); } catch (Exception err) { err.printStackTrace(); } } public static void main(String argv[]) { new CommandExection("c:\\CompChamps.exe"); }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

LinkBacks (?)
LinkBack to this Thread: http://www.java-forums.org/java-tips/3296-how-execute-external-program-through-java-program.html
Posted By For Type Date
Java on Linux FC4 This thread Refback 09-22-2007 11:37 PM
Web to execute commands in other machines This thread Refback 09-22-2007 11:35 PM
CrossFTP 1.37 Released This thread Refback 09-22-2007 08:47 PM

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to execute an External Program through Java program Java Tip java.io 0 04-04-2008 03:40 PM
External Program execution problems vital101 Advanced Java 3 10-30-2007 06:17 PM
Use a external file in my program romina New To Java 1 08-07-2007 06:28 AM
Execute a new program in java mathias Advanced Java 1 07-31-2007 06:42 AM
Need to write a program to execute a list of system commands mdthahir Networking 1 07-27-2007 06:46 PM


All times are GMT +3. The time now is 10:36 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org