Calling external process in Java

Ads

 
 

Share on Google+Share on Google+

Deepak Kumar
Calling external process in Java
1 Answer(s)      7 years ago
Posted in : Java Beginners
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
Ads
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();
}

Ads









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
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 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
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
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
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
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
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
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
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 - Development process
Java Sort String Array  How to sort string array in Java
java reflection - Development process
java reflection  how to save and run reflection class in java?please immediately reply sir
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
ipad external display tutorial
ipad external display tutorial  Hi, I am looking for a iPad external display tutorial. I have a VGA adapter but my application need to support it to show anything on external device. Please suggest me. Thanks
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
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

Ads

 
Advertisement null

Ads