B4J Question Run jar exstras dinamical

ivanomonti

Well-Known Member
Licensed User
Hi,,,,,

I need to launch the module jar from a secondary menu extra, I used this code, but without results


B4X:
Sub bt_extras_Action
    ' path = C:\Users\MONIVA\odrive\Box\B4IOSP~1\PROJEC~1\ASSOCI~1\Objects\Moduli\test.jar
    Dim item As MenuItem = Sender
    Dim path  As String = File.Combine(File.DirApp, item.Tag)
    Dim sh As Shell
    sh.Initialize("sh",path,Null)
    sh.Run(-1)
End Sub
Thank
 

ivanomonti

Well-Known Member
Licensed User
Thank

I used this code and it works, but now the problem and how to pass values to variables!!

B4X:
Sub bt_extras_Action
    Dim item As MenuItem = Sender
    Dim path  As String = item.Tag
    Dim folder As String = File.DirApp & "\\Moduli"
    If File.Exists(folder,item.Tag) = True Then
        Dim sh As Shell
           sh.Initialize("sh", "java", Array As String("-jar", path))
           sh.WorkingDirectory =folder
          sh.Run(-1) 'set a timeout of 10 seconds
    Else
        Return
    End If
End Sub
 

Daestrum

Well-Known Member
Licensed User
Pass them after the jar file name, they will be treated as strings, then in the called jar they will be available in the args() array.

ie, java -jar myJarFileToRunWithShell arg1 arg2 arg3

Spaces separate the items so if you sent hello world, that is two arguments. To make it one argument enclose in double quotes "hello world".
 

micro

Well-Known Member
Licensed User
Hi to all
I used this code but external jar not run:
B4X:
Dim javaexe As String
javaexe = File.Combine(GetSystemProperty("java.home", ""), "bin/java")
sh.Initialize("sh", javaexe & " -jar " & File.GetUri(File.DirApp, "Socketj.jar"), Null)
sh.Run(-1)
In sh_ProcessCompleted, Success return always False.
where am I wrong?
 
Top