### B4J Library create using B4J

Steps to create a B4J Library using B4J.
Step 1: Create the yourlibrary.b4j file
Region Project Attributes
#LibraryName: YourLibrary
#LibraryVersion: 1.0
#LibraryAuthor: YourName
End Region
Note: The LibraryName is the name of the jar and xml file, which is stored in the additional libraries folder.
' There are no globals declared in the B4J file
`Sub Process_Globals
End Sub`
' AppStart is doing nothing
`Sub AppStart (Form1 As Form, Args() As String)
End Sub`
Step 2: Create yourlibrary.bas file
In the B4J IDE, select Project > Add New Module > Class Module
Enter class name yourlibrary.bas
Build your library methods, like below example.
Note: This example does not use a form, but calls a dialog from a JavaObject Jave Class Swing OptionPane.
`Sub Class_Globals
Private fx As JFX
End Sub`
'Initializes the object. You can add parameters to this method if needed.
`Public Sub Initialize
End Sub`
' Show Messagedialog
' Parameter Message as String
`Public Sub showMessage(strMsg As String)
' Define the JavaObject
Dim jo As JavaObject
' Initialize using the Swing Library class JOptionPane
jo.InitializeStatic("javax.swing.JOptionPane")
' Show the message
jo.RunMethod("showMessageDialog", Array As Object(Null, strMsg))
End Sub`
Step 3: Compile your project to a library
Select Project > Compile To Library and the yourlibrary.jar and xml will be created in the additional library folder.
Ensure to specify the additional libraries folder under Tools > Configure Path.
Step 4: Use yourlibrary (Version: 1.00) in your project
Start the B4J IDE, load your project and select yourlibrary from the IDE Libs tab.

Changed: , Category: Libraries, File: T6C214M1555.htm, ID: 1555