Running exe from java

Hi,

I whant to run the iReport from my java swing application.

I think I'm missing somethimg..

I get this error:

Java virtual machine launcher

Could not fined the main class, program will exit.

publicclass runApp{

Process proc;

runApp(){

String str ="C:\\MyJava\\iReport-1.3.0\\iReport.exe";

try{

proc = Runtime.getRuntime().exec(str);

if (proc.waitFor() != 0){

System.err.println("Program did not finish properly");

}

}catch (Exception e1){

// TODO Auto-generated catch block

e1.printStackTrace();

}

}

publicstaticvoid main(String[] argz){

new runApp();

}

}

I'm thinking that I'm missing some file to complite iReport running. (with this code I get the same error).

maybe I need to set more files to run this app?

If I coppy to some place in the computer only the iReport.exe file - then click on it to run this program, I get the same erro :)

[1726 byte] By [yael800a] at [2007-11-26 18:15:42]
# 1
[deleted]Message was edited by: sabre150
sabre150a at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 2
How do you launch the application? What do you type?Kaj
kajbja at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 3

I don't fully understand:)

If I whant to open the iReport not from java swing, I'm just clicking on the iReport.exe shortcut.

If I whant to open from java, I have a JButton and from button click I whant to open the iReport (to create a new reporn).

this is my small example for you to understand my problem.

Thank you very much,

yael

yael800a at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 4
When do you get the error message: "Could not fined the main class, program will exit."Kaj
kajbja at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 5

I get this error when I'm running this code, and I was try to check if it is about my code (not attached to java):

If I coppy to some place in the computer only the iReport.exe file - then click on it to run this program, I get this error to.

but if I'm running from the shortcut desctop or from the exe that located in the iReport directory (whit no attached to java) it's running good.

so, I think this error dialog attached to iReport program.

maybe I need add to this code more files to run the iReport?

yael800a at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 6

Your Java code works fine on my computer.

I only changed the line

String str = "........

so that it pointed to a real ".exe" file on my computer.

When I ran your Java application, the ".exe" file was opened perfectly.

So, there might be a Java configuration problem with your system.

Java_Lavaa at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 7
Did you tried to run the iReport.exe? or progam else?Becous I thinking the problem is specipic whit iReport running.anyway, what did you write on the string path?
yael800a at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 8
It worked fine for me as well...Why dont you try to run your local word or excel with the same program.. This will tell you if there is a config problem ;-)-TC
AbiSSa at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 9
I check it now, I can run any programes exapt iReport exe.I run successfull MySQL Manager 3 & Babylon.
yael800a at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 10
THen obviously you need some other components to run the program or maybe some native code..-TC
AbiSSa at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 11
Do you have any example?Thanks alot
yael800a at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 12
> "Could not fined the main class, program will exit."That indicates that the OP isn't able to execute the Java program. Not that it fails to execute the exe. That's why I asked how the OP is executing the program. He's invoking java on the wrong class.Kaj
kajbja at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 13
mmm..so How I neew to invoking?
yael800a at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 14
> mmm..so How I neew to invoking?You should now how you are trying to start the program! We can't answer that.
kajbja at 2007-7-9 5:49:14 > top of Java-index,Java Essentials,Java Programming...
# 15
I don't understan you, you meen:1)how I start iReport program with no java? --> I just click on the shortcun exe.2)Or how I starn my java program? --> I'm running this code.3)Or how I start to run iReport from java? --> with the code that I was possed to
yael800a at 2007-7-21 17:19:37 > top of Java-index,Java Essentials,Java Programming...
# 16
I guess you understood that my post should say know and not now :)> 2)Or how I starn my java program? --> I'm running> this code.Yes, but how do you run it? What to you type? Where do you type it?Kaj
kajbja at 2007-7-21 17:19:37 > top of Java-index,Java Essentials,Java Programming...
# 17

Thenk you Kaj for all your help.

I'm running my java program with Eclips, so, I don't type nothing.

eclips local:

C:\Program Files\Java\eclipse\eclipse.exe

iReport local:

C:\MyJava\iReport-1.3.0\iReport.exe

eclips work space:

C:\MyJava

My java project local:

C:\MyJava\MyJavaProject

jdk-1_5_0_09-windows-i586-p.exe &

C:\Program Files\Java

yael800a at 2007-7-21 17:19:37 > top of Java-index,Java Essentials,Java Programming...
# 18
> Thenk you Kaj for all your help.> I'm running my java program with Eclips, so, I don't> type nothing.It still sounds like you are executing the wrong class from within eclipse.Kaj
kajbja at 2007-7-21 17:19:37 > top of Java-index,Java Essentials,Java Programming...
# 19

I have the same problem of that link, maybe you'll understand somthing?

http://forum.java.sun.com/thread.jspa?threadID=782614&messageID=4451148

in the iReport.bat:

@echo off

set CMD_LINE_ARGS=

:setArgs

if ""%1""=="""" goto doneSetArgs

set CMD_LINE_ARGS=%CMD_LINE_ARGS% %1

shift

goto setArgs

:doneSetArgs

cd bin

startup.bat %CMD_LINE_ARGS%

if Irun from the cmd this line - it's running:

C:\\MyJava\\iReport-1.3.0\\iReport.exe

I tried this code to:

try {

Runtime.getRuntime().exec("C:\\MyJava\\iReport-1.3.0\\iReport.exe /c start c:\\iReport.bat");

} catch (IOException e1) {

// TODO Auto-generated catch block

e1.printStackTrace();

}

Or

String [] cmds = {"cmd.exe","/c","\"C:\\MyJava\\iReport-1.3.0\\iReport.exe\""};

try {

Process p = Runtime.getRuntime().exec(cmds);

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

Message was edited by:

yael800

yael800a at 2007-7-21 17:19:37 > top of Java-index,Java Essentials,Java Programming...
# 20
What happens if you add a System.out.println("blah blah") to the beginning of main. Can you see that message?Kaj
kajbja at 2007-7-21 17:19:37 > top of Java-index,Java Essentials,Java Programming...
# 21

thanks alot for your help, the unswer to run this is to run the startup.bat

String[] cmds = { "cmd.exe", "/c",

"\"C:\\MyJava\\iReport-1.3.0\\bin\\startup.bat\"" };

yael800a at 2007-7-21 17:19:37 > top of Java-index,Java Essentials,Java Programming...
# 22

> thanks alot for your help, the unswer to run this is

> to run the startup.bat

> > String[] cmds = { "cmd.exe", "/c",

> "\"C:\\MyJava\\iReport-1.3.0\\bin\\startup.bat\""

> t\"" };

>

I don't have a clue about what you are saying. Does that mean that you have solved the problem?

kajbja at 2007-7-21 17:19:37 > top of Java-index,Java Essentials,Java Programming...
# 23

Yes!!!

The problem was that I run

Runtime.getRuntime().exec("C:\\MyJava\\iReport-1.3.0\\iReport.exe");

iReport run from the startup.bat:

Runtime.getRuntime().exec("C:\\MyJava\\iReport-1.3.0\\bin\\startup.bat");

it's write in the iReport .bat so I tried to run this file

cd bin

startup.bat %CMD_LINE_ARGS%

yael800a at 2007-7-21 17:19:37 > top of Java-index,Java Essentials,Java Programming...