Execute a jar in my program!

Hello everyvbody,

I have an application that has to execute a jar, but i cant seem to get it to work. I tried many different things, creating a .bat file that calls the jat, then calling the bat file, i tried calling the cmd.exe and and then sending the dos command to start the jar, but none of this worked.

It keeps on giving me

CreateProcess: d:\docume~1\pw44500\desktop\aimsta~1\aimsta~1.jar error=193

How can i call this other jar?!?

Thanks alot for your help!

Thanks alot

[523 byte] By [AlexMaca] at [2007-10-3 2:19:38]
# 1
Do you want to run the jar or would it work better to just include the jar in your code and call the class directly?Please post a short working example of code of what you have and use the code format tags.
zadoka at 2007-7-14 19:18:32 > top of Java-index,Java Essentials,New To Java...
# 2

Here is what i have to do, There is a tread looping in a folder checking if a new file is created. Once a file is created, it copies and renames the file into another folder. I then call the JAR to execute some other commands on this file.

I unfortunatly dont have access to the code of this JAR so no way to go add the watch over there. The watch and copying are working fine, the only thing left, is to call the jar.

So far i have tried many things, even creating a .bat file that calls the .jar and calling that instead.

Runtime.getRuntime().exec("cmd /C d:\\docume~1\\pw44500\\desktop\\aimsta~1\\aimsta~1.jar");

absolutley nothing happenes. I tried this different ways,

Runtime.getRuntime().exec("d:\\docume~1\\pw44500\\desktop\\aimsta~1\\aimsta~1.jar");

and i tried the same code with run.bat instead of aimsta~1.jar and again nothing.

Thanks for your help!!!

AlexMaca at 2007-7-14 19:18:32 > top of Java-index,Java Essentials,New To Java...
# 3
Oh yeah the second way i mentioned,Runtime.getRuntime().exec("d:\\docume~1\\pw44500\\desktop\\aimsta~1\\aimsta~1.jar"); gives me the following mistake :CreateProcess: d:\docume~1\pw44500\desktop\aimsta~1\aimsta~1.jar error=193
AlexMaca at 2007-7-14 19:18:32 > top of Java-index,Java Essentials,New To Java...
# 4

> Oh yeah the second way i mentioned,

> Runtime.getRuntime().exec("d:\\docume~1\\pw44500

> \\desktop\\aimsta~1\\aimsta~1.jar");

gives me

> the following mistake :

> CreateProcess:

> d:\docume~1\pw44500\desktop\aimsta~1\aimsta~1.jar

> error=193

try

Runtime.getRuntime().exec("java -jar d:\\docume~1\\pw44500\\desktop\\aimsta~1\\aimsta~1.jar");

PMJaina at 2007-7-14 19:18:32 > top of Java-index,Java Essentials,New To Java...
# 5

It works!!! Thanks

What was giving me a problem was the fact that the JAR i was trying to launch had to acces some properties file and it was making the application crash because i wasn't calling it from the same folder.

I dont know if this is normal, but i copied the JAR and all of its properties files to my workspace and now it works....

Thanks alot

AlexMaca at 2007-7-14 19:18:32 > top of Java-index,Java Essentials,New To Java...