I have been studying JNI (Java Native Interface) since last month.It is really interesting .I mean call Java functions from C and vice versa.Now I have an intention call linux command which I mentioned above like sed,awk from Java side.also I have a little bit knowledge about Sell Script in linux. please give me some hint how to do this.
            Asked
            
        
        
            Active
            
        
            Viewed 841 times
        
    2 Answers
1
            
            
        You should Runtime.exec() or ProcessBuilder depending on what you require to execute process into your local system.
This questsions could help:
1
            
            
        You could use this java snippet to run a shell command:
Process process = Runtime.getRuntime().exec("echo This is a test"); //Start the process
process.waitFor(); //Wait for the process to terminate
BufferedReader reader = new BufferedReader(new InputStreamReader(process.getInputStream())); //Get the output
 
    
    
        mewking
        
- 13
- 3
 
     
    