I have a java file named MemoryComparison.java
kept in the folder D:\Documents\CodeAnalysis\project_analysis_RG\CodeAnalysis\input\master\Kajari_G
I have another folder D:\Documents\CodeAnalysis\output\
where I want to store the output of the above java file after execution.
In the Java program MemoryComparison.java I have not given any package name.
Now, I am compiling and executing the above java program from another java program named ReadFilesInFolders.java
. Below is the code snippet:
try {
Runtime.getRuntime().exec("javac input\\master\\Kajari_G\\MemoryComparison.java");
Runtime.getRuntime().exec("java -cp input\\master\\Kajari_G\\ MemoryComparison > output\\output1.txt");
} catch (IOException e) {
e.printStackTrace();
}
Now, the first exec is working fine and the .class file is getting generated in the same folder, where MemoryComparison.java is. But it seems the second exec is not working as no output1.txt is getting created.
But when I am running the above two lines from the command prompt, everything is working fine and the output1.txt is getting created.
Can you please help me with this!