Calling external process in Java

Calling external process in Java

Hi,

How I can call some system command from Java? I want to run the Microsoft Calculator application from Java, how it can be done. Provide me example.

What is the use of Runtime.getRuntime().exec(?.) command.

Thanks
View Answers

September 8, 2012 at 3:23 PM

In a very general way:

try {

     String[] cmds = {path+"/*.exe"};
     Process proc = Runtime.getRuntime().exec(cmds);
} catch (Exception e) {

     e.printStackTrace();
}

for your question:

try {

     Process proc = Runtime.getRuntime().exec("calc.exe");
} catch (Exception e) {

     e.printStackTrace();
}









Related Tutorials/Questions & Answers:
Calling external process in Java - Java Beginners
Calling external process in Java  Hi, How I can call some system command from Java? I want to run the Microsoft Calculator application from Java, how it can be done. Provide me example. What is the use of Runtime.getRuntime
Java process
Java process  How will you invoke any external process in Java
Advertisements
calling a java file in java
calling a java file in java  how to call a another java file in java
calling method - Java Beginners
calling method   class A{ public void fo(){ class B{ public void fo1(){ System.out.println("fo1 of class B"); } } System.out.println("fo of class A"); } class C{ public void fo2
calling java beans - JSP-Servlet
calling java beans  Sir, I want to know where to place the java beans java file and class file inside tomcat web server. and how to call them from jsp file.  Hi Friend, Java Bean is placed in classes\form
Calling exe through Java program. - Java Beginners
Calling exe through Java program.  Hi, How to call a vb exe that takes one argument , using a Java program. Thank You, Umesh Kilkile ... IOException{ Runtime r=Runtime.getRuntime(); Process p=null; try { String s="C
Process in Java
Process in Java  how can I execute a java program as a process which i can monitor it in the task manager to see the cpu usage
How to run external command in Python?
How to run external command in Python?  Hi, I am writing an application in Python and there is requirement of calling the external command from the Python program. I spend some time but could not find good example of calling
javac is not ecognised as internal and external command - Java Beginners
javac is not ecognised as internal and external command  i have... is not recognised as internal and external command.please reply me as soon as possible  Hi Friend, It seems that either java is not installed
Calling java class method from javascript
Calling java class method from javascript  I want to call a java class method from javascript. The java class method is like "public String[] getWord()". I want to assign this string array value to a variable in javascript. I
Error in calling javascript function from java
Error in calling javascript function from java  I am callin javascriot function from applet and getting error netscape.javascript.JSException: Unexpected error: This method should not be used unless loaded from plugin.jar
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
video calling
video calling  how to implement video calling using java? i am a final year mca student please give me some samplecodes
Implement Java clients calling Web Services
Implement Java clients calling Web... the enterprise components Next    Implement Java clients calling Web Services Generating a Java client proxy and a sample
java code - Development process
java code  hi, this is sampath, how to acchive the batch processing in java or batch process base java thread. can u send the code and brief explanation. thanks and regards sampath reddy
core java ,io operation,calling methods using switch cases
core java ,io operation,calling methods using switch cases  How to create a dictionary program,providing user inputs using io operations with switch cases and providing different options for searching,editing,storing meanings
process of compiling and running java program
process of compiling and running java program  Explain the process of compiling and running java program. Also Explain type casting
Thread and Process - Java Beginners
, VijayaBabu.M  Hi vijayaBabu A process can contain multiple threads. In most multithreading operating systems, a process gets its own memory address... process. For instance, a JVM runs in a single process in the host O/S. Threads
core java - Development process
. The process is known instantiation For example : class... to : http://www.roseindia.net/java/master-java/java-object-oriented-language.shtml
Calling Destructor
Calling Destructor  How can i call destructor in java using System.gc() or manually. Please anyone give me a example program   Java... to the file."); } } Java Garbage Collection using System.gc
ejb calling from jsf - Java Server Faces Questions
ejb calling from jsf  1st i take list of person then i try to edit...) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java:1042) at com.sun.corba.ee.impl.encoding.CDRInputStream_1_0.read_value(CDRInputStream_1_0.java
send ACK to external device
send ACK to external device  i want to do connection with an external device that make medical tests to send to it a message but, this device should... to make that with java code
java - Development process
java  hi, can u send an example code in MVC Architecture for gym process i just want to get register id from database for citizen .then he will add is suggestion in text box and submit it i am sending jsp page u will get idea
JAVA - Development process
StreamResult("data.xml"); initXML(); process(test...(); handler.startElement("","","Roseindia",atts); } public static void process (String s
Calling a function
Calling a function  Hi, I have a function xyz() in php code. When a button is clicked it should execute that particular function for that i have written as <form action="<?=$_SERVER['PHP_SELF'];?>" method="post">
java - Development process
Java Sort String Array  How to sort string array in Java
Java Steps - Development process
Java Steps  what are the steps to be taken to create a mobile phone compatible java swing program
java server - Development process
java server  Develop multi-threaded echo server and a corresponding GUI client in java
java with linux - Development process
java with linux  HI , This is namit.I want to know how to link a java program with linux platform
java with alfresco - Development process
java with alfresco  how to write java code to upload different documents and search options using alfresco api
java reflection - Development process
java reflection  how to save and run reflection class in java?please immediately reply sir
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
how to start intergrated webcam of a laptop without calling its exe file using java only - Java Beginners
how to start intergrated webcam of a laptop without calling its exe file using java only  how to open integrated webcam of a laptop without calling its exe file using java only?.simply what i am asking is that is there any method
java programming - Development process
java programming  Design a class for Complex numbers in Java. In addition to methods for basic operations on complex numbers, provide a method... the following link: http://www.roseindia.net/tutorial/java/core
Java programing - Development process
Java programing  1.What is system.out and system.in? 2.write down the steps to run Java application 3.what are the function of the following methods a.show input dialogue message. b.show output dialogue message
java - Development process
java  Develop multi-threaded echo server and a corresponding GUI client in Java
java - Development process
java  how to store the names in database in binary tree format using the java code
java project - Development process
java project   Can you tell me how to design a windmill software
java beginning - Development process
java beginning  sir, i am literaly a beginner and i just want to askthat what are the uses of learning java because i have listened about... the following links: http://www.roseindia.net/java/ http://www.roseindia.net/java
Java - Development process
Programming in Java  How to program my first application in Java? Other then Hello World
Java_Weblogic - Development process
Java_Weblogic  How to run as service bea weblogic server on unix mode
java charts - Development process
java charts  Hi,i want to create charts wrt database by using jsp?please help me
java - Development process
java  Could you please explain me how to use composite primary key in the java persistent api with example
Java - Development process
Java   hi everybody, my problem is how to produce commandprompt through java code and how to open a particular .exe file with this code...plz could any one solve my problem....waiting for the reply,..... thank
java script - Development process
java script  how could i devlop code for create widget. i need to generate java script that if paste to any other web site will generate the widget. a widget can contain image text video or combination
Java Project - Development process
Java Project  Hello Sir I want Java Project for Time Table of Buses.that helps to search specific Bus Time and also add ,Update,Delete the Bus Routes. Back End MS Access Plz Give Me
java - Development process
java  Develop Date class in Java similar to the one available in java.util package. Use JavaDoc comments and the output.please reply must sir. .../tutorial/java/core/implementDateclass.html Thanks
java - Development process
java  [Mini-Project] Develop a programmer's editor in Java that supports syntax highlighting, compilation support, debugging support, etc.please reply me sir
Java - Development process
Java  Q 1- write a program in java to generate Armstrong numbers up to a specific limit? Q2- write a program in java to check a given number... the sum of geometric series?a+ar+ar^2+ar^3+??+ar^n-1 Q 6- write a program in java
Java - Development process
to integrate the two or more class in java language.please send the message... to integrate two java program. u can integrate java pro with other software or tool. To integrate 2 java programs use "is a relationship" and "has a relationship" ie

Ads