B4J Question Execute jar from B4J How to?

uniplan

Active Member
Licensed User
Longtime User
I would run from my B4J application another .jar application.
The two applications run in Windows environment.
it's possible? How?

if it were possible I would like to also have the ability to kill at a later time the process I launched.
 

uniplan

Active Member
Licensed User
Longtime User
I tried the library Jshell with this code:

B4X:
Dim shl As Shell
   shl.Initialize("shl","B4JwebApp.jar",Null)
   shl.WorkingDirectory = "G:\moduli_software\B4J-BrokerD\test"
   shl.Run(10000) 'set a timeout of 10 seconds

But I have this error:

Error: org.apache.commons.exec.ExecuteException: Execution failed (Exit value: -559038737. Caused by java.io.IOException:
Cannot run program "B4JwebApp.jar" (in directory "G:\moduli_software\B4J-BrokerD\test"): CreateProcess error=2, Can not find the file specified)

I am sure that the file is in specified path.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Look at post #13 in that same thread. You should do something like:
B4X:
shl.Initialize("shl", "java.exe" , ArrayAsString("-jar", "Server_report.jar",name))

The idea is to run java.exe with the "-jar" parameter, followed by your app name (ending in ".jar") and its parameter (if any).
 
Upvote 0

uniplan

Active Member
Licensed User
Longtime User
Look at post #13 in that same thread. You should do something like:
B4X:
shl.Initialize("shl", "java.exe" , ArrayAsString("-jar", "Server_report.jar",name))

The idea is to run java.exe with the "-jar" parameter, followed by your app name (ending in ".jar") and its parameter (if any).

I try it and is OK.
Thanks.
 
Upvote 0
Top