B4J Question How to execute a jar from a jar

mauro vicamini

Active Member
Licensed User
Hello Evryone!
I've developed an application that need to execute a server jar for working.
For execute the jar from inside I use this code:
B4X:
            File.Copy(File.DirAssets,"TDeviceLabServer2.jar",File.DirData("TLAB"),"TDeviceLabServer2.jar")
sh1.Initialize("shl", "java.exe" , Array As String("-jar", File.Combine(File.DirData("TLAB"),"TDeviceLabServer2.jar")))
            
sh1.WorkingDirectory = File.DirData("TLAB")
sh1.Run(-1)
In the ide all works ok.
When I build the package with B4jPackager and install the application and then I run it, it's not able to execute
B4X:
sh1.Initialize("shl", "java.exe" , Array As String("-jar", File.Combine(File.DirData("TLAB"),"TDeviceLabServer2.jar")))
Infact in the folder runtime/bin of the application there is not the java.exe but only the java.dll.
How could I resolve this kind of problem?

Thanks for the attention.
 

xulihang

Active Member
Licensed User
The extension .exe is not necessary and not cross-platform. I use jshell to run other jars, too and I find that it will automatically use the java environment which it runs on.
 
Last edited:
Top