Problem with Runtime.exec()
I will have to execute IReports tool in click of a button. I wrote the following lines in button's actionPerformed:
Process p=Runtime.getRuntime().exec("C:/iReport/iReport.exe");
I have iReport.exe in a folder iReport in c:/;Its not opening and giving me a JavaVirtualMachineLauncher dialog box with this message "Couldnot find Main Class.Program will exit"...I tried with other exe like:notepad.exe and explorer.exe; Is there anything that i should add or do?
[480 byte] By [
Sruthi.ma] at [2007-10-3 8:56:54]

> Now i tried it ..but not working...
> Is it true that
> ...you cant execute processes written in java thru
> runtime.exec() method..
No.
> and if you want to run them
> you should create an object of their main class file
> in your method ....
It's generally better to use the classes than to start up another JVM process. But rather than use the main class, it's even better to use the classes as an API. IMO anyway.
By the way, you're overusing ellipses.
Mr.paulcw,
i am working on -using API.
Mr.AFlood,
My window opens when I run the program.Then I click on the button and a dialog box appears with message "Couldnot find Main Class.Program will exit".The path of the exe file is correct and I can execute it from command promt. This is the status.
Apparently the .exe finds and invokes the right class, somehow, and apparently that mechanism is broken when invoked with Runtime.exec. My feeling is that if this is the case, then the .exe is **** and should be avoided anyway. And so you should use the API of the code, if available.
Otherwise...does the .exe expect any environment variables to be set? Maybe that's the problem.