B4J Question B4JPackager fails with non-UI jar

Brian Dean

Well-Known Member
Licensed User
Longtime User
I have used B4A for several years but I have only just tried using B4J, and I am still testing things out with small sample apps. I have used B4JPackager successfully in several previous trials. Now I am trying to package an app and get an error. This is my first non-UI app, but that might not be connected.

Here is the app ...

B4X:
'Non-UI application (console / server application)
#Region Project Attributes
    #CommandLineArgs:
    #MergeLibraries: True
#End Region

Sub Process_Globals
   
    Dim url As String                                            ' URL passed from caller
    Dim dest As String                                        ' Destination file from caller
   
End Sub

Sub AppStart (Args() As String)
    If (Args.Length = 2) Then
        url = Args(0)
        dest = Args(1)
    Else
        ExitApplication                                            ' Missing argument
    End If
    downloadAndSave                                                ' Do the job
    StartMessageLoop
End Sub

'Return true to allow the default exceptions handler to handle the uncaught exception.
Sub Application_Error (Error As Exception, StackTrace As String) As Boolean
    Return True
End Sub

Sub downloadAndSave
    Dim destDir As String                                    ' Destination folder
    Dim destFilename As String                        ' Destination file
    dest.Replace("/", "\")
    Dim p As Int = dest.LastIndexOf("\")
    destDir = dest.SubString2(0, p)
    destFilename = dest.SubString(p + 1)
    Dim j As HttpJob
    j.Initialize("", Me)
    j.Download(url)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        File.WriteString(destDir, destFilename, j.GetString)
    End If
    j.Release
    StopMessageLoop
    ExitApplication

... and here is the error ...

B4JPackager11 Version 1.13
InputJar: C:\Basic4Java\urltofile\Objects\urltofile.jar
Running: C:\Basic4Java\B4JPackager11\Objects\temp\FindDosPath.exe
Running: C:\Java\jdk-11.0.1\bin\jar
main._appstart (java line: 106)
java.lang.RuntimeException: java.lang.IllegalStateException: No match found
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:120)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at anywheresoftware.b4a.keywords.Common$3.run(Common.java:1086)
at anywheresoftware.b4a.keywords.SimpleMessageLoop.runMessageLoop(SimpleMessageLoop.java:30)
at anywheresoftware.b4a.StandardBA.startMessageLoop(StandardBA.java:26)
at anywheresoftware.b4a.keywords.Common.StartMessageLoop(Common.java:153)
at b4j.example.main._appstart(main.java:106)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:91)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:78)
at b4j.example.main.main(main.java:28)
Caused by: java.lang.IllegalStateException: No match found
at java.base/java.util.regex.Matcher.group(Matcher.java:645)
at anywheresoftware.b4a.keywords.Regex$MatcherWrapper.Group(Regex.java:154)
at b4j.example.main$ResumableSub_FindPackageName.resume(main.java:522)
at anywheresoftware.b4a.BA.checkAndRunWaitForEvent(BA.java:136)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:85)
... 13 more

Can you tell me where I should be looking?
 
Last edited:

Brian Dean

Well-Known Member
Licensed User
Longtime User
Thanks Erel.

I was planning to write a helper utility in Java that I could execute from another (non-Java) application. It doesn't sound as though that is possible.

But maybe I could try a UI app with a hidden form off screen.
 
Upvote 0
Top