0

To clarify, I'm trying to write a program that grades if a program is run correctly. When a .java file is in the same directory, it runs the file and captures the output to a String so it can check if it is the right answer.

The files that are entered will grab data from a text file, manipulate it, and out.print(); so the program needs to be able to capture the output to see if the program submitted works and its answers match a database of answers.

0

1 Answer 1

0

You can use process class to run any executable in java code.

Process process = Runtime.getRuntime().exec(" // command to execute java code");

process.waitFor();

It will execute any executable.

process object will give different type of streams.

process.getInputStream();

process.getOutputStream();

process.getErrorStream();

from that stream you can retrieve the output.

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.