2

I am trying to run my shell script using java program. I am getting following exception.

java.io.IOException: Cannot run program "/home/builder/code/target/classes/idFetcher.sh": java.io.IOException: error=13, Permission denied
    at java.lang.ProcessBuilder.start(ProcessBuilder.java:460)
    at java.lang.Runtime.exec(Runtime.java:605)
    at java.lang.Runtime.exec(Runtime.java:443)
    at java.lang.Runtime.exec(Runtime.java:340)
    at script.InformationFetcher.main(InformationFetcher.java:26)

The path of file is correct and file is present at that location. Here is my code

package script;

import java.io.IOException;

public class InformationFetcher {

    public InformationFetcher() {
    }

    public static void main(String[] args) {
    try {
        InformationFetcher informationFetcher = new InformationFetcher();
        Runtime.getRuntime().exec(informationFetcher.getFilePath());
    } catch (IOException e) {
        e.printStackTrace();
    }

    }

    public String getFilePath() {
    return this.getClass().getResource("/idFetcher.sh").getPath();
    }

}
4
  • This should help. I think, you have a similar issue. stackoverflow.com/questions/14684713/… Commented Jul 16, 2014 at 20:25
  • 5
    Make sure your shell script has the right execute permission for owner , group, and global. Commented Jul 16, 2014 at 20:25
  • 1
    chmod +x might help... Commented Jul 16, 2014 at 20:26
  • Thank you everyone. It was a permission issue. Commented Jul 16, 2014 at 20:55

1 Answer 1

1

Make the shell script executable for the user

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.