How is this different from executing the javac and java programs with the classes to be tested?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Do you mean something like JUnit, where you define test cases and it runs them and checks that the results are correct?
JamesCherrill
... trying to help
8,533 posts since Apr 2008
Reputation Points: 2,583
Solved Threads: 1,456
Skill Endorsements: 30
What "evaluations" are done to the code?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
compile and run java program
The javac program will compile a program. The java program will execute a program.
There is a Compiler class and JavaCompiler interface that could be used in a program to compile a java source.
The class's main method could be called to execute the program.
with sets of test cases
What are the "test cases"? Are they files that the program is to read?
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
You can change System.in by using a System class method.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
I got stuck by providing the test cases or inputs to that program ...
If the user submitting the code does not provide input for test cases, I have no idea how a program could generate it.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
In general, a program can not generate input for another program without knowing a lot about what input the program expects and the order it should be in.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
providing Input to a program using another program..
Where does the program being tested get the the input?
From a disk file,
from System.in,
from somewhere else???
I assume that the contents of the input has been provided by the person that submits the program for testing.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
Please explain what the problem is you are having executing this code so I'll know what to look for when (or if) I test it.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16
trying to provide Input to Main1.java's scanner object(sc)
The code runs in a separate JVM: exeCode("java Main1"). I don't know how to change System.in for that.
The Process class has methods to connect to the input stream.
NormR1
Posting Sage
7,742 posts since Jun 2010
Reputation Points: 1,158
Solved Threads: 793
Skill Endorsements: 16