I have one program which uses command line arguments for doing particular work. But when I am calling the main function from another program with appropriate arguments into string array, it does not work as it is working and giving output from the command line.
I have also tried "Runtime.exec()" method to call the class having main method, but results none.
Is there another way to perform the this opration?
Hi Rajshkhr Pandey,
Do you mean in following example, when you run Test2.main() it is not printing anything?
It works for me
~ Chandrakant Talele
Joined: Oct 13, 2005
Welcome to the Ranch
That is probably not what the question is about, I am afraid, since that will obviously work readily.
Joined: Dec 08, 2008
Oops , yes I interpreted the problem incorrectly, my apologies
Here is the sample program that will work. I hope I am correct this time.
I am running it in eclipse and "bin" is where my .class files are.
Probably all problems that can occur using Runtime.exec are explained in this article.
If you can alter the code for both applications, the easiest would probably be to add an appropriate constructor to the app being called through which you can pass the parameters, and then to instantiate (and run) it directly.