Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

How will you invoke any external process in Java?

user-image
Question ajoutée par Mohd shahnawaz khan , Associate Project , Cognizant Technology Solution
Date de publication: 2014/04/16
Mufeed Farhan
par Mufeed Farhan , HR Applications Manager , SBM

We can invoke the external process in Java using exec() method of Runtime Class .

 

Example Below:

import java.io.*;

public class Main

{      

public static void main(String args[])

{           

try {               

Runtime rt = Runtime.getRuntime();               

Process pr = rt.exec("c:\\\\helloworld.exe");               

BufferedReader input = new BufferedReader(new InputStreamReader(pr.getInputStream()));               

String line=null;               

while((line=input.readLine()) != null)

{                    System.out.println(line);               

               int exitVal = pr.waitFor();               

System.out.println("Exited with error code "+exitVal);           

} catch(Exception e)

{               

System.out.println(e.toString());               

e.printStackTrace();           

}        }}

 

Copied From:

http://www.javaken.com/forum/showthread.php?t=2749 .

 

yahia dekar
par yahia dekar , ingenieur d'etat en informatique , universite djilali liabbes - sidi bel abbes

exec

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?