You can put more than one java application in a single jar, but still be able to run them as individual applications.
The main advantage is the space it takes up.
For example, a simple non-ui program
Takes about 91Kb when compiled to a jar.
If you had three similar programs, that's around 270Kb total on disk.
If you make a single program with 3 entry points, that does exactly the same as the three separate programs, it works out around 94Kb. Thus saving you ~180Kb of disk space and faster to download to/send to another computer.
Making the multi-entry point jar is easy
a, for each application - change the package name
ie, application#1 - package name = 'b4j.example.class1'
application#2 - package name = 'b4j.example.class2'
application#3 - package name = 'b4j.example.class3'
b, compile in release application#2 and #3
c, in main application #1, add the #AdditionalJars: for application #2 & #3
d, compile in release application #1
to run them from a batch file requires a minor change (assuming .bat file is in the same directory as the jar files)
They will run as if separate applications, but they exist in only one jar file.
The downside is - if you change 1 application, you have 2 to compile again (the one that changed and the main application to include the new changed jar)
The main advantage is the space it takes up.
For example, a simple non-ui program
B4X:
...
Sub AppStart (Args() As String)
Log("from class1")
End Sub
...
If you had three similar programs, that's around 270Kb total on disk.
If you make a single program with 3 entry points, that does exactly the same as the three separate programs, it works out around 94Kb. Thus saving you ~180Kb of disk space and faster to download to/send to another computer.
Making the multi-entry point jar is easy
a, for each application - change the package name
ie, application#1 - package name = 'b4j.example.class1'
application#2 - package name = 'b4j.example.class2'
application#3 - package name = 'b4j.example.class3'
b, compile in release application#2 and #3
c, in main application #1, add the #AdditionalJars: for application #2 & #3
d, compile in release application #1
to run them from a batch file requires a minor change (assuming .bat file is in the same directory as the jar files)
B4X:
java -cp ./class1.jar b4j.example.class1.main
java -cp ./class1.jar b4j.example.class2.main
java -cp ./class1.jar b4j.example.class3.main
The downside is - if you change 1 application, you have 2 to compile again (the one that changed and the main application to include the new changed jar)