B4J Question How to build ui-app with B4JPackager11 ?

jinyistudio

Well-Known Member
Licensed User
Longtime User
Hi
My UI APP will use the shell to execute two none-ui jars. How do I package them together with B4JPackager11?
 

aeric

Expert
Licensed User
Longtime User
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
I always get following exception when i execute other jar from UI-APP(build by B4JPackager11) ? o_O
Exception in thread "main" java.lang.IllegalAccessError: class com.ab.template.main (in unnamed module @0x64c64813) cannot access class anywheresoftware.b4a.StandardBA (in module b4j) because module b4j does not export anywheresoftware.b4a to unnamed module @0x64c64813
at com.ab.template.main.<clinit>(main.java:11)
B4X:
Dim p1 As List
    p1.Initialize
    p1.Add($"java"$)
    p1.Add($"-jar"$)
    p1.Add($"lgmtengine.jar"$)
    p1.Add($"${EngId},${linegatePt}"$)
    ExecuteJar("execengine",p1,showcmd)
   
    Sub ExecuteJar(event As String,params As List,showwnd As Boolean) As String
    If DetectOS<>1 And False Then
        ' linux
        Dim shl As Shell
        shl.Initialize(event, "java" , params)
        Dim s1 As String = shl.Arguments
        'shl.Initialize("shl", "cmd" , params)
        shl.WorkingDirectory = File.DirApp
        shl.Run(-1)
        ' shl.RunWithOutputEvents(-1)
        Dim rets As String="java"
        For Each s1 As String In params
            rets = $"${rets} ${s1}"$
        Next
        Return rets
    Else
        ' window
        If showwnd Then
            params.InsertAt(0,"start")
        End If
        'params.InsertAt(0,"/k")
        params.InsertAt(0,"/c")
        Dim shl As Shell
        shl.Initialize(event,"cmd",params)
        shl.WorkingDirectory = File.DirApp
        shl.Run(-1)
    End If
End Sub
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
Same result o_O
B4X:
Dim p1 As List
p1.Initialize  
p1.Add($"-jar"$)
p1.Add($"linegatemt.jar"$)
p1.Add($"alone"$)
ExecuteJar("execgate",p1)

Dim p1 As List
p1.Initialize  
p1.Add($"-jar"$)
p1.Add($"lgmtengine.jar"$)
p1.Add($"${EngId},${linegatePt}"$)
ExecuteJar("execengine",p1)

Sub ExecuteJar(event As String,params As List) As String
    Dim shl As Shell
    shl.Initialize(event, "java" , params)
    Dim s1 As String = shl.Arguments
    'shl.Initialize("shl", "cmd" , params)
    shl.WorkingDirectory = File.DirApp
    shl.Run(-1)
    ' shl.RunWithOutputEvents(-1)
    Dim rets As String="java"
    For Each s1 As String In params
        rets = $"${rets} ${s1}"$
    Next
    Return rets  
End Sub
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Start with running it from the command line. It requires some work to find all the required modules.

To run a simple non-ui project:
B4X:
java -cp nn.jar --add-opens b4j/anywheresoftware.b4a=ALL-UNNAMED  --add-opens b4j/anywheresoftware.b4a.keywords=ALL-UNNAMED b4j.nonui.main

Based on the error message you will need to add more of these "add-opens" arguments.
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
The result of execution o_O
B4X:
D:\jylab\project\b4j\linegatemt\Objects>jre\bin\java -cp linegatemt.jar --add-opens b4j/anywheresoftware.b4a=ALL-UNNAMED --add-opens b4j/anywheresoftware.b4a.keywords=ALL-UMNAMED b4j.nonui.main
WARNING: Unknown module: b4j specified to --add-opens
WARNING: Unknown module: b4j specified to --add-opens
Error: Could not find or load main class b4j.nonui.main
Caused by: java.lang.ClassNotFoundException: b4j.nonui.main
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
my no-ui app use jylab. it is my library(.jar+.xml). Next, how can I put jylab in the ui package ? o_O

B4X:
D:\jylab\project\b4j\linegateboot\Objects\temp\build\bin>java -cp linegatemt.jar --add-opens b4j/anywheresoftware.b4a=ALL-UNNAMED  --add-opens b4j/anywheresoftware.b4a.keywords=ALL-UNNAMED com.ab.linegate.main
main.initializeProcessGlobals (java line: 274)
java.lang.NoClassDefFoundError: b4j/example/jylab
        at com.ab.linegate.main.initializeProcessGlobals(main.java:274)
        at com.ab.linegate.main.main(main.java:27)
Caused by: java.lang.ClassNotFoundException: b4j.example.jylab
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(Unknown Source)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(Unknown Source)
        at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
        ... 2 more
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
the jar is too large !
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Solution:

1. Make sure that the non-ui has a different package name.
2. Add all the dependencies to the main project.
3. Add to the main project:
B4X:
#AdditionalJar: C:\Users\H\Documents\...\SecondAppCompiledJar.jar

4. Start the second app with:
B4X:
java.exe @release_java_modules.txt  -m b4j/second.app.package.main
 
Upvote 0

jinyistudio

Well-Known Member
Licensed User
Longtime User
sorry ! What is dependencies ?:oops:
 
Upvote 0
Top