Getting Started with B4J

A few questions

  1. is there a “preferred” JDK for use with this (Azul, openjdk ?)
  2. need both the JDK And javaFX installed ?

JDk 11 or 14 downloadable on the b4x homepage. And both needs to be installed. The JDk of b4x comes with included javafx

In the B4J page, you can find the links to the JDK.
The Recommended versions are OpenJDK 14 and OpenJFX 14:

Yeah I’m good now
:slight_smile:
I’ll have way more questions for folks who’ve used it later :stuck_out_tongue:

ask and when and if you have further questions I am sure that Erel will help you with all needed informations.

So in a B4J web app is there the notion of "Session’ OR is each connected WebSocket roughly “a session” ?

Sorry - trying to relate this to what little I know from Xojo web apps where each session is an object

About webapps in B4j I would contact @Alwaysbusy because Alain is the maker of the toolkit insluding the use of the Visual Designer. I hope he is reading this message so he can provide the needed infromations as I am writing Webapps with JavaFX or with Vaadin always! But he can tell you more about the possible ways to provide Web Applications. If you speak about a Webserver only for a JavaScript FrontEnd he is always the BEST contact in case of B4x. I can provide only informations about Java also in this case. Hope he has all you need.

No t as xojo, B4J web apps are a little lower level.

B4J has a powerful (real) multithreaded Server and a LOT of functionality in the framework BUT it is not RAD.

You can start here for the basics:

The Chatroom example may shed some light on this: [WebApp] Chatroom - Threads, Sessions and Server events | B4X Programming Forum

There are roughly two ways to make WebApps in B4J:

  1. jServer + WebSockets (you can use ABMaterial for the UI, but it is not mandatory). This is the native B4J solution using jQuery, is not RAD. The ABMaterial library (Java) is open source. The WebSocket and JQueryElement objects are the ones you use most.

  2. jServer as backend for the REST API (but can use WebSockets too) + BANano for the PWA. It can be handled in one project., however I find it easier to just make two separate projects. Both jServer as BANano are RAD in this case, (even more than Xojo IMHO) as both support Hot Code Swapping, meaning you can write code (or make changes in the Abstract Designer for the UI part), press save and the changes are immediately visible in the browser without having to recompile/transpile the whole project. Here, the BANanoObject and BANanoElement are your best friends.

Most of our projects in my day job are now of type 2. They are fast both in development and end-product. BANano also allows inline JavaScript/CSS right into the B4X code.

I suggest skimming through the booklet if you are interested in BANano development: [Web][BANano] Website/App/PWA library with Abstract Designer support | B4X Programming Forum

Specific questions are best asked in the B4J forum. If it is ABMaterial or BANano related use the [ABMaterial] or [BANano] prefix in the subject as this is what I scan for.

2 Likes

B4J Banano is RAD Ivan, sorry. What you describe is the B4J Server as native Server. B4J Banano is another animal.

Tested Liberica JDK 20

I downloaded Liberica JDK 20 as full JDK (full JDK means with integrated JavaFX) today and tried it with B4J. There was no errormessage.


This Picture shows one of the B4J examples running on Liberica FullJDK Java 20 with JavaFX 20. So it is possible to run with modern Java and modern JavaFX still in support.

Also I was running the example WebAp from B4J Website (Examples). After correcting the needed older version of the Server (the Example is really old, needed Version 52 which I corrected to be able to use 55) it was also running without any problem.

So the use of modern Java distributions with included JavaFX (it is important that it is with JavaFX included and integrated into the JDK like it was with Java 8 and Java11) is going on without problems.

By the way I tested on an Ubuntu Linux machine with Crossover Office which is also running without problems. I did not tested the newer Crossover Office under MacOS but I guess that should also work.

Why isthis important?

Because Java is a modern Software with lonbg time maintenance and Support it is important to be able to use the now supported Versions. At the moment Java 17 as LTS Version is supported until 2030 which is also running with all the programs (also fully tested). Java 20 is the actual short time supported Version, Java 21 will release soon as the next LTS Version with Support until 2032.

Since Java 21 is jet not released I will test this also after release.

So writing of JavaFX Desktop Software, Java command Line programs and Java WebApplications with Banano and also B4J Server as native Web application are possible without any problem.

By the way, with the command jpackage it is possible to build an install-package on all platforms the liberica JDK is running on, at the moment this is posible:

Windows (Arm, X86), MacOS (Arm. X86), Linux (Arm, X86, PowerPC). Hold in memory: to build native running applications and installers you need to do the jpackage on the platforms you want to support and test there also your Software.

Also working: Android and IOS with B4A and B4I for programming for Android and IOS.

Good Job @erel and @Alwaysbusy

PS: it would be really nice if somebody would test this also on MacOS with codeweafers Crossover for MacOS, I believe that it will work like this also but I don’t know. So please test it and report here.

Also tested: B4R for MCU programming, runs also. Complex: the use of USB Devices with Codewafers. Workaround: install the OS native Software for copying the Software to the MCU. We had good success on Linux and on MacOS with this.

2 Likes