B4J Question B4J: how to debug UI app under Linux ?

peacemaker

Expert
Licensed User
Longtime User
HI, All

I have the B4J app that works under Win10 OK.

I have tried to start it under Linux Mint, understood 2 errors in the console after app crash, updated some for Linux based subs - and app is started under Linux !
It was prepared under Linux with help of this manual: https://www.b4x.com/android/forum/t...-intel-amd-computers-and-vpss.159928/#content

Starting with help of B4JPackager11 and java/linux_jdk-14.0.1.zip was unsuccessful: programmatically creating by B4JPackager11 "temp" folder is always with "root"-owner, and unaccessible.

Successful start was so:
sudo java -jar --module-path /usr/share/openjfx/lib --add-modules ALL-MODULE-PATH ~/pcbc2/pcbcomparer2.jar
1738316141376.jpeg

But the app has just 2 differences from working under Win10:
  1. Mouse wheel: zooming in and out does not work well, i will record a video how it looks.
  2. There is the error "XSetErrorHandler() called with a GDK error trap pushed. Don't do that." that was mentioned here: https://www.b4x.com/android/forum/threads/solved-wayland-to-x11-error-in-ubuntu-22-04-with-jdk-11-0-1.141090/#post-893856
But such start with "-Djdk.gtk.version=2" does not help:
sudo java -jar -Djdk.gtk.version=2 --module-path /usr/share/openjfx/lib --add-modules ALL-MODULE-PATH ~/pcbc2/pcbcomparer2.jar

So, question: how to debug B4J development under Linux, and see the error point ?
 

EnriqueGonzalez

Expert
Licensed User
Longtime User
With b4j bridge
 
Upvote 0

EnriqueGonzalez

Expert
Licensed User
Longtime User
You don't need to load the javafz libraries during the bridge initialization, just make sure that the jdk you are using has access to those modules, and if this is not a raspberry, you don't need to run with sudo, I guess you are using the same jdk version for both ?

Not sure if those suggestions will allow you to show something, try with a simpler one, may be a console app or a server.
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
It was JDK14. If to set JDK11 - it showed the error:

Error occurred during initialization of VM
java.nio.charset.IllegalCharsetNameException: UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -Dprism.maxvram=2G
at java.nio.charset.Charset.checkName(java.base/Charset.java:308)
at java.nio.charset.Charset.lookup2(java.base/Charset.java:482)
at java.nio.charset.Charset.lookup(java.base/Charset.java:462)
at java.nio.charset.Charset.defaultCharset(java.base/Charset.java:608)
at sun.nio.cs.StreamEncoder.forOutputStreamWriter(java.base/StreamEncoder.java:56)
at java.io_OutputStreamWriter.<init>(java.base/OutputStreamWriter.java:110)
at java.io.PrintStream.<init>(java.base/PrintStream.java:110)
at java.io.PrintStream.<init>(java.base/PrintStream.java:148)
at java.lang.System.newPrintStream(java.base/System.java:1892)
at java.lang.System.initPhase1(java.base/System.java:1968)

and after i removed

#PackagerProperty: VMArgs = -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -Dprism.maxvram=2G
#VirtualMachineArgs: -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8 -Dprism.maxvram=2G

... the app is started at Linux side!
And moreover - the dialog with the template started to work ! It means that the error has turned out to ... the warning, without app crash:

(java:13118): Gdk-WARNING **: 15:29:32.417: XSetErrorHandler() called with a GDK error trap pushed. Don't do that.

But the pictures from SQLite db are not shown now... :confused:.
Fully mess...

BTW: "Main.fx.ShowExternalDocument("http://...)" - does not work, no web-browser opened.
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Latest results.
1) If to start the JAR using OpenJDK 19 and JavaFX that were installed as:

sudo apt install openjdk-19-jdk
sudo apt-get install openjfx
by command line:
sudo java -jar --module-path /usr/share/openjfx/lib --add-modules ALL-MODULE-PATH ~/pcbc2/pcbcomparer2.jar

... the mouse wheel zoom works NORMALLY as under Win10, and the trouble is only with "Wait For (dialog.ShowTemplate(...." that crashes the app.
-------------------------

2) But debugging via B4J-bridge on the remote Linux desktop does not work (immediately "ProcessCompleted" just after "Connected ! Starting program", without any error messages). And it's if to start bridge by using JDK11 or JDK14 with JavaFX modules found.

If B4J-bridge is started without JavaFX modules - it's for sure UI app cannot be debugged, with error:

Error: --add-modules= requires modules to be specified
, and starting bridge by OpenJDK 19:
sudo java -jar --module-path /usr/share/openjfx/lib --add-modules ALL-MODULE-PATH ~/pcbc2/b4j-bridge.jar
is always without JavaFX modules found.



So, question is again actual - how to setup all to debug B4J UI app on a remote Linux desktop via B4J-bridge WITH MODERN Java and JavaFX modules (that provide correct work mostly) in 2025 ?
 
Last edited:
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
Thanks, Erel. For me debugging works only with Java11 and without " -Dfile.encoding=UTF-8 -Dsun.stdout.encoding=UTF-8 -Dsun.stderr.encoding=UTF-8".
I hate desktop Linux already, as a developer...
 
Upvote 0
Top