-2

I've an error in this code:

    String rollno="13f127";
    String file="code";
    Process p = Runtime.getRuntime().exec("C:\\Users\\Raga\\Documents\\"+rollno+"\\"+file+".py < C:\\Users\\Raga\\Documents\\"+rollno+"\\input.txt");

I don't know how to create that process and what's wrong in this line. Please help anyone!

I've seen this type of questions earlier but in my problem, I'm using to compile python program with the input given from the file. So I want to know how this one differs!

Varshini
  • 187
  • 1
  • 6
  • 20

1 Answers1

1

You are trying to execute a non-executable python file.

Try using the "python" (provided you have python installed) command as you would do from the cmd to execute python scripts.

Example:

Process p = Runtime.getRuntime().exec("python C:\\Users\\Raga\\Documents\\"+rollno+"\\"+file+".py < C:\\Users\\Raga\\Documents\\"+rollno+"\\input.txt");