Android Tutorial Custom class templates


B4X founder
Staff member
Licensed User
Longtime User
Starting from B4A v8.0 it is possible to include custom class templates inside your libraries. Note that it will also be added to B4J and B4i.

You can include multiple templates.

There are two steps:
1. Add the template files to the project. File extension must be .b4x_excluded.
For example B4J jServer library now includes the three server handlers:


2. Declare them with the new @CustomClasses annotation:
@CustomClasses(values = {
       @CustomClass(name = "Server Handler", fileNameWithoutExtension = "server_handler"),
       @CustomClass(name = "Server Filter", fileNameWithoutExtension = "server_filter"),
       @CustomClass(name = "Server WebSocket", fileNameWithoutExtension = "server_websocket")
@DependsOn(values={"jetty_b4j", "c3p0-", "c3p0-oracle-thin-extras-"
       ,"mchange-commons-java-0.2.11", "json"})
public class ServerWrapper {

If you are using SLC to build the library then you should put the files in the 'additional' folder.

The jar structure should be:


Make sure to use BADoclet v1.07+. The updated doclet is available inside SLC.

The generated XML should end with:
    <customClass>name:Server Handler, filenamewithoutextension:server_handler</customClass>
    <customClass>name:Server Filter, filenamewithoutextension:server_filter</customClass>
    <customClass>name:Server WebSocket, filenamewithoutextension:server_websocket</customClass>

See this link if you want to create a custom class template without building a library:
Last edited:


Licensed User
Longtime User
So it is possible to create it only in Java. It is not possible with the B4A libraries