B4J Question Is it possible to get the name of the current application in B4J console app

Patrick Clark

Active Member
Licensed User
is it possible to get the name of the .jar that is currently being executed.

eg: form the command line I run
B4X:
java -cp test.jar b4j.example.main
I would like to be able to get "test.jar" within code.

if I run
B4X:
java -cp full.jar b4j.example.main
I would like to get "full.jar"

If i can get the "b4j.example" that I can set in the build options that would do.

Thanks
 

thetahsk

Active Member
Licensed User
Longtime User
If you have the JDK installed you can use jps.exe.
see https://docs.oracle.com/javase/7/docs/technotes/tools/share/jps.html
B4X:
Sub Button1_Click
    xui.MsgboxAsync("Hello Process World!", "B4X")
    Dim shl As Shell
    shl.Initialize("shl", "jps.exe", Array As String("-l"))
    shl.Run(10000) 'set a timeout of 10 seconds
End Sub

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