B4J Question Run jar exstras dinamical

ivanomonti

Expert
Licensed User
Longtime 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

Expert
Licensed User
Longtime 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
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime 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".
 
Upvote 0

micro

Well-Known Member
Licensed User
Longtime 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?
 
Upvote 0
Top