B4J Tutorial B4J tutorial for Basic4android developers

B4J development tool is similar to Basic4android. The language and IDE are mostly identical.

The APIs (methods, keywords and libraries) are identical in some cases and different in other cases.

I converted existing frameworks such as DBUtils, HttpUtils2, DateUtils, RDC, ImageDownloader and others from B4A to B4J. It was simpler than I expected it to be. In some cases no changes were required at all.


There are two types of modules in B4J. Code modules and classes. Classes are identical to B4A classes.
Code modules are similar to B4A modules however they are more powerful as they can handle events.

A code module can be considered as a class with exactly one instance (such instances are sometimes called singletons or static classes). Activities and Services are not required in B4J. You should instead use code modules. Note that when you add an existing B4A activity or service to B4J project it will be converted to a code module.

CallSub is mostly not required in B4J as you can directly call methods of other classes or code modules.

Generally speaking it is simpler to develop with B4J as you do not need to deal with the activities (and services) life cycle. This also means that there is no such concept as "activity object".


The main difference is in the UI. B4J is based on JavaFX UI and Basic4android is based on the native Android UI.

It is worth going over Oracle Scene Builder tutorials to better understand the UI. Once you understand how the UI integrates with B4J code then the other concepts such as the "event name" concept are the same.

Colors - In Basic4android colors are represented as Ints (2 bytes for Alpha, R, G, and B). In B4J colors are represented as Paints.
You can use fx.Colors.From32bit to convert an Int value to a Paint.

This tutorial will be expanded in the future...

Doug Johnson

Licensed User
Make sure you are connected to your device in (B4A) under Tools/B4A Bridge and select wireless or Bluetooth toy your device.

BTW. This is posted in the wrong spot B4J does not have rapid debugger.

I am getting this message from B4J so it is in the right section and your suggestion does not seem to apply......


Licensed User
Out of curiosity, will it run in release Mode?


Well-Known Member
Licensed User
Make sure you are connected to your device in (B4A) under Tools/B4A Bridge and select wireless or Bluetooth to your device.

BTW. This is posted in the wrong spot B4J does not have rapid debugger.
"CORRECTION" per Erel there is a rapid debugger in B4J it is the same as B4A.
In B4A there is a drop down for rapid debug mode I was not aware of this in B4J because its not a drop down. Normally I have seen the above error in B4A. My apologizes for misinforming.

colin van Blommestein

Licensed User
Do B4J apps run on Android smart phones?

Is there a B4J bridge app (as in B4A) to link an Android smartphone to a PC ?

How do I import a library into B4J?


Licensed User
Very nice but as you say B4J creates as Jar file so its is Java, why not use Netbeans and java directly?


Staff member
Licensed User
Not sure that I understand the logic here. A jar file is similar to an exe file. You can also say "C++ creates an exe file so why not use Assembler".

B4J allows you to easily create desktop, server and web apps. With the same language as B4A and with very similar libraries.

If you are an experienced Java developer (with server and websockets experience) then you can use Java instead of B4J. If not then it will be easier to use B4J.


New Member
Licensed User
thanks Erel and everyone else who has contributed to these b4x projects. As someone who has been stuck on vb6 syntax for years and found it challenging to learn new languages, I now feel like the sky is the limit as I transition away from Windows desktop apps which are so 90s into WebApps and Mobile. All while working with the VB syntax I am very familiar and comfortable with. Thank you Thank you ThankYOU :):):)


Licensed User
I have to say, I would pay for a "pro" version that somehow brought the two dev environments closer together. The ability to build both Windows, mac, and android apps from the same place would easily add value.

You see it in the likes of YoYo Game Maker and it makes developing one app for all platforms much more straight forward. Whilst I appreciate it wouldn't be 'straight forward' as such, some how bringing the dev suits together and charging, say, a few hundred dollars...well...you'd get my money.


Mark Zraik

Licensed User
Hi Erel,

Years ago I developed in Java 2 and other languages. This is way easier and as you stated, the B4A and B4J coding is almost identical!
Porting from B4A to B4j and visa versa is absolutely cool and easy - Hardly any modifications at all. Copy and Paste is MY FRIEND!
There are other ways, too using the library compilations functions.
Thank you Erel and all who contributed to B4X. Tooo many to list!