B4J Library [tool] Compile project with different version of Java

Don't use this. Starting from B4J v8.80 there is a built-in option (#JavaCompilerPath): https://www.b4x.com/android/forum/threads/b4j-v8-80-has-been-released-šŸ¾.125536/#content

1. Download the attached jar and put it in B4J internal folder. Not in the libraries folder.

2. Add these comments to your project:
'Compile with Java 8:  ide://run?file=%B4X%\ProjectCompiler.jar&VMArgs=-Db4x%3D%B4X%&Args=-Task%3DBuild&Args=-BaseFolder%3D..&VMArgs=-Djavabin%3DC:\Program+Files\Java\jdk1.8.0_211\bin
'Compile with Java 14: ide://run?file=%B4X%\ProjectCompiler.jar&VMArgs=-Db4x%3D%B4X%&Args=-Task%3DBuild&Args=-BaseFolder%3D..&VMArgs=-Djavabin%3DC:\jdk-14.0.1\bin

3. Change the last parameter based on your java path. Note that you need to replace spaces with + and (, ) with %28 and %29.
4. Ctrl + click on the links to compile.


  • ProjectCompiler.jar
    146.6 KB · Views: 355
Last edited:


B4X founder
Staff member
Licensed User
Longtime User
Source code of this utility:
Sub AppStart (Args() As String)
    Log("Project Compiler v1.00")
    Dim inifolder As String = File.Combine(File.DirData("Anywhere Software"), "B4J")
    If File.Exists(inifolder, "b4xV5.ini") = False Then
        Log("Can't find B4J ini file.")
    End If
    Dim javabin As String = GetSystemProperty("javabin", "")
    Log($"javabin: ${javabin}"$)
    If File.Exists(javabin, "javac.exe") = False Then
        Log("Can't find javac.exe")
    End If
    File.Copy(inifolder, "b4xV5.ini", inifolder, "inibackup.bak")
    Dim ini As List = File.ReadList(inifolder, "b4xV5.ini")
    For i = 0 To ini.Size - 1
        Dim line As String = ini.Get(i)
        If line.StartsWith("JavaBin") Then
            ini.Set(i, $"JavaBin=${javabin}"$)
        End If
    File.WriteList(inifolder, "b4xV5.ini", ini)
        Dim builder As String = File.Combine(GetSystemProperty("b4x", ""), "B4JBuilder.exe")
        Dim shl As Shell
        shl.Initialize("", builder, Args)
        Dim res As ShellSyncResult = shl.RunSynchronous(60000)
        Log($"Exit code: ${res.ExitCode}
StdOut: ${res.StdOut}
StdErr: ${res.StdErr}
    End Try
    File.Copy(inifolder, "inibackup.bak", inifolder, "b4xV5.ini")
End Sub

Tobias Leininger

Licensed User
Longtime User
Different compiler heap sizes, full error messages, integration with B4X-Bridge.
But then I'll add those things myself or keep changing the SDK path.

Tobias Leininger

Licensed User
Longtime User
The full error message will be in the logs.

Why??? Never encountered a case where it needs to be changed.
How can you do it with changing the SDK path?

Integrating with B4J-Bridge will be much more complicated.

Old Java 8 doesn't like very large compiler heap sizes on my machine, while newer ones do. And for some projects I need larger values.

Right now I just have a batch file doing changes to the ini file to switch between different versions.