B4J Code Snippet [B4J] Restart App

aeric

Expert
Licensed User
Longtime User
mean javac.exe
javac.exe is for compiling java class. e.g javac.exe App.java
java.exe can be use to call java compiled jar or other use. e.g java.exe -jar xxxxx.jar or java.exe -m xxxxxx

First, let's understand B4J produces jar file using JDK 11+ but this is not user friendly.
Windows users prefer to use exe format so they can just double-click and run.
Maybe some B4X developers confused with the exe compiled from VB or VB.Net

Java applications need to use JVM to run
B4J IDE has build-in the Build Standalone Package feature which make an exe format easier.
BUT this exe is not the same exe like what produce by Visual Studio or VB.

Once the packaging completed, there are 2 exe files.
To run our app, we execute the java.exe or App.exe inside the \bin folder which required to pass some parameters such as the module names. I don't know how the magic actually works but this is what I understand.
The packager has bundled together with a java.exe and other required files to let you run the java app without Java runtime or JDK installed.

If you don't want to pass more parameters, it is better use the App.exe 1 level up, it make things a bit easier.
If you don't want to use that, it is fine to just use the App.exe inside the \bin folder but you need to pass some parameters.
 

T201016

Active Member
Licensed User
Longtime User
I am not sure how you produce the exe. Are you using Launch4j to create a single exe?

Of course, I used the Launch4j compiler to create the .exe file. This way I avoid providing any parameters. Remember that the simplest methods create an application that is safer to run.
 

Magma

Expert
Licensed User
Longtime User
@aeric
you are right - i was confused:

a debug batch file:
B4X:
    cd bin
java.exe @release_java_modules.txt --add-opens b4j/org.bridj=ALL-UNNAMED --add-opens b4j/org.bridj.cpp=ALL-UNNAMED --add-opens java.base/sun.security.ssl=b4j -m b4j/b4j.example.main
pause

java.exe

...not sleeping well... :-(

anyway - not using launch4j... too / using -> b4j / standalone

ps: i am gonna get a - cant wake up
 
Last edited:

aeric

Expert
Licensed User
Longtime User
I think many members are not aware.
This is not documented any where.
I discovered this myself and may not 100% correct.
 

T201016

Active Member
Licensed User
Longtime User
Now I know.
I am not sure what you mean by Launch4j is safer.
I don't use Launch4j for some reasons.
Of course, it was not my intention to evaluate the Launch4j tool in relation to other such auxiliary tools, I just wanted to draw attention to the fact that wherever possible, you should absolutely use simple (read: less complicated) methods rather than those that may result in various unforeseen problems regarding generally understood security conditions. And Launch4j is fortunately still developing in the right direction.
 

aeric

Expert
Licensed User
Longtime User
I can say using Launch4j is a personal choice.
I can argue and give my points it is not better than the standalone package in many ways.
Good that it serve you well.
If you are curious to know my points, let's start a new thread.
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…