B4J Question java.exe arguments in shell

le_toubib

Active Member
Licensed User
Longtime User
hi all
this didn't run , what am i doing wrong ?
java.exe arguments in shell:
    Dim shl As Shell
    Try
        shl.Initialize("shl","java.exe", Array As String("-Xms1024m","-Xmx1024m", "-jar", "D:\test.jar"))
        shl.WorkingDirectory="D:\"
        shl.Run(-1)
    Catch
        Log(LastException.Message)
    End Try
thanks
 

Gandalf

Member
Licensed User
Longtime User
Try adding this sub:

B4X:
Sub shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)
    If Success And ExitCode = 0 Then
        Log(StdOut)
    Else
        Log("Error: " & StdErr)
    End If
End Sub

And look what will be in the logs. If there's nothing, try setting timeout in shl.Run (instead of -1, set something like 3000, which is 3 seconds)
 
Upvote 0

le_toubib

Active Member
Licensed User
Longtime User

i set timeout to 3000 , i'm not sure if it reached to shl_ProcessCompleted ,
i got this error log:
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
you could try something like
B4X:
    Dim shl As Shell
    Dim parms As List
    parms.Initialize
    parms.Add("-Xms1024m")
    parms.Add("-Xmx1024m")
    parms.Add("-jar")
    parms.Add("test.jar")
    shl.Initialize("shl","java.exe", parms)
    shl.WorkingDirectory="d:/"

    shl.Run(-1)
    
    Wait For shl_ProcessCompleted (Success As Boolean, ExitCode As Int, StdOut As String, StdErr As String)

    If Success Then
        Log("Success")
        Log(StdOut)
        Log(ExitCode)
    Else
        Log("Error: " & StdErr)
    End If
 
Upvote 0

le_toubib

Active Member
Licensed User
Longtime User
i tried the above fragment , i got the error below ,


timer3 tick is where this fragment is executed . it used to run very well this way :
shl.Initialize("shl","java.exe", Array As String("-jar", "D:\test.jar"))
but problems arised when i added more arguments
 
Upvote 0

le_toubib

Active Member
Licensed User
Longtime User
Why use a timer?
Timer set the time to execute this code fragment. It's disabled before execution, there's no repeat.
No, test.Jar didn't use any arguments.

I meant java.Exe arguments , - jar worked fine, but adding -Xms1024m and -Xmx1024m caused the problem.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…