B4J: The True Successor of MS VB6

By | 2017-01-10

The title may be surprising but let me extend it further in this blog article. The first question we should ask us is:

What is B4J?
A development tool for cross platform development, i e B4J creates solutions for Windows, Linux, Apple et al. It also creates Console applications. It’s also a server side development platform mainly for internal use. It can also be used to develop solutions for IoT (Internet of Things), and Non-UI applications for Raspberry Pi.

A very interesting point is that we use a Visual Basic like syntax to develop and when compiling the output is Java software, i e executable JAR files. Not only that, it’s possible to get obfuscated releases of the software, which makes it difficult to read the code solution.

B4J is part of the B4X “package” which also includes the below list of tools that share the same concept as B4J. That is, using Visual Basic like code to develop and to produce Java Software for different platforms:

  • B4A for the Android platform
  • B4i for the iOS platform
  • B4R for the Arduino platform
  • (B4J for Desktop, Console, Server and Raspberry Pi)

To a large extent they share the same code base. All in all, I find B4X to be an excellent companion for developing modern software on all popular platforms. In later blog entries I will introduce B4A and how to create software for the Android platform.

The Development Platform
It has a simple IDE but it’s a rather powerful IDE. Basically it offers what can be required for a modern IDE, including intellisense and code formatting. It’s easy to navigate around and it’s simple to find what we are looking for. Of course, B4J has its learning curve but not that steep like Visual Studio.NET.

B4J shows some similarities with the now dead Jabaco programming language. It has a Visual Basic like syntax that VB(A) developers can adapt rather quickly.

The following screen shot shows the main windows, including the code editor and the tab with libraries:

There exist a friendly and strong committed community for B4J. A major indication of that is the existence of a large number of free libraries for various tasks (Look on the right side of the above screen shot and You’ll see some of them.).

B4J can be customized, we can select theme for the IDE and also theme for the code editor, font type and font size, word wrap and more.

Even if the internal Visual Designer differences from the classic VB(A) Visual Designer it’s straight forward and we get easy up to speed. It also includes a WYSIWG Designer as the following screen shot of the internal Designer also shows:

B4j offers most of the basic GUI controls. What is great is that we can tweak the UI by using CSS. The internal Designer offers also a Designer Script editor to help to fine tune the layout which the below screen shot also shows:

In B4J’s Visual Designer we work with layouts. For instance, suppose we have a form and a Tab control with three tabs. That means that we can work with four layouts, one for each tab and one for the form. When we get used to it we will realize how powerful this approach is. We can fine tune a software that will run on desktop computers and Pads with differences screen resolutions by loading difference layout depending on which device we use.

Working with the Debugger is straight forward. It does the work well without any whistle and bells.

Visual Basic like Syntax
B4J uses a Visual Basic like syntax. As a die-hard VB developer I really appreciate it as we can get up to speed rather fast and quickly see results of our efforts.

The following code snippet shows a sample of the syntax used in B4J:

Sub btDelete_Action

Dim sqlDelete As String = "DELETE FROM tbl_Main WHERE Software = "

If gSQL.IsInitialized=False Then
gSQL.InitializeSQLite(File.DirApp, "licmans.db", True)
End If

If tfSoftware.Text <> "" Then
Try 'Does the item exist?
If gSQL.ExecQuerySingleResult2("SELECT Count(*) FROM tbl_Main WHERE Software=?;", Array As String(tfSoftware.Text)) = 0 Then
cutils.ShowNotification3(stTitle, "The Software does not exist!", cutils.ICON_INFORMATION, MainForm, "CENTER", 2000)
Return
End If
Catch
cutils.ShowNotification3(stTitle, LastException.Message, cutils.ICON_INFORMATION, MainForm, "CENTER", 2000)
End Try

Try
gSQL.ExecNonQuery(sqlDelete & "'" & tfSoftware.text & "';")
cutils.ShowNotification3(stTitle, "Record successfully deleted!", cutils.ICON_INFORMATION, MainForm, "CENTER", 2000)

cmbSelect.Items.RemoveAt(cmbSelect.SelectedIndex)
cmbSelect.SelectedIndex=-1

DBUtils.ExecuteTableView(gSQL,sqlSoftware,Null,0,tvSoftware)
Catch
cutils.ShowNotification3(stTitle, LastException.Message, cutils.ICON_WARNING, MainForm, "CENTER", 2000)
End Try
Else
cutils.ShowNotification3(stTitle, "The Software field cannot be empty!", cutils.ICON_INFORMATION, MainForm, "CENTER", 2000)
End If

Restore_Data

Dim iCounter As Int
For iCounter = 0 To tvSoftware.ColumnsCount -1
ResizeToFit(tvSoftware, iCounter)
Next

End Sub

Another great feature of B4J is that we can also use JavaFX controls and code to extend B4J capability. Of course, this make B4J ever more powerful.

B4J is indeed a Rapid Application Development (RAD) tool. It separating code from UI design and it’s easy to update/change.

Sample – Application running on Windows 10
I just want to show how it looks when running an application in Windows 10 developed with B4J.

The application is a license manager and I use it myself. Since I don’t want to show my own list of software I have added some fiction software.

Summary:

Manage individual records:

Additional B4J Resources on the Internet:

We must keep in mind that B4J is still under development. In other words, more features are expected to be added.

Finally, B4J together with B4R are both free and will be free for ever!

In an upcoming blog entry I will in detail discuss how we can control MS Excel with B4j in a Console application.

All the best,
Dennis

One thought on “B4J: The True Successor of MS VB6

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.