0

We are building a grading system, and part of its job is to take input files, and from the given directory, our system will compile and run a (non-java) source code file written by the students. Then, the system will display the output from that run.

It is not limited to python, any other language that can meet the requirement is OK.

Is there is any method for providing for the location of the python code and the input file, and then run that code, returning the output file. If not, how can i achieve this goal?

Sachin Jain
21.9k34 gold badges113 silver badges177 bronze badges
asked Apr 3, 2014 at 0:24

1 Answer 1

1

Take a look at the Runtime class. In particular, look at Runtime.exec(). It should enable you to execute external applications from within your Java program, as well as passing command line arguments, and specifying working directory.

Note that the python or any other program must have some well-defined way to get its input and write its output, such as passing filenames on the command line, or reading from stdin.

answered Apr 3, 2014 at 0:30
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.