Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

A small issue while trying to execute "R" package using JAVA getting Exited with error code 2 could any one pls help me out...

        Runtime run = Runtime.getRuntime(); 
        Process pr = null;
        String line=null;
        BufferedReader input = null;
        try {
            pr = run.exec("cmd /c R");
            input = new BufferedReader(new InputStreamReader(pr.getInputStream()));
            while((line=input.readLine()) != null) {
              System.out.println(line); 
            }
            int exitVal = pr.waitFor();
            System.out.println("Exited with error code "+exitVal);
        } catch (Exception e) {         
            e.printStackTrace();
        } 
share|improve this question
1  
You can start accepting answers too – Jigar Joshi May 17 '11 at 5:06

1 Answer

On Windows exit code 2 generally means "file not found". Check in which folder are you are running the "cmd /c R". You can test this by creating a new file and then search your computer where it was created, or by executing the dir.exe command and then checking the result.

share|improve this answer
if i try the same command from command line its working – Tapsi May 17 '11 at 5:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.