Hello,
B4J Bridge doesn't run jars anymore on Windows with Java 11. With java 8, no problems, but I now encounter this problem when executing my jar on another Windows Machine:
After testing a bit, I came up with a solution, which is to modify this function in B4j-Bridge source code:
It works for me, but maybe needs more polishing?
In any case, this B4j-bridge is a great tool, thank you!
edit: changed the title
B4J Bridge doesn't run jars anymore on Windows with Java 11. With java 8, no problems, but I now encounter this problem when executing my jar on another Windows Machine:
The other machine has the bundle JavaFX + OpenJDK installed, and set in the PATH correctly. The problem is that JavaFX is not loaded properly.Error: JavaFX runtime components are missing, and are required to run this application
After testing a bit, I came up with a solution, which is to modify this function in B4j-Bridge source code:
B4X:
Sub Streams_NewStream (Dir As String, FileName As String)
If shl.IsInitialized Then shl.KillProcess
'new file has arrived
Log("Starting program")
Dim jo As JavaObject
jo.InitializeNewInstance("java.io.File", Array As String(File.Combine(Dir, FileName)))
jo.RunMethod("setExecutable", Array As Object(True, False))
Dim args As List
args.Initialize
args.Add("-Dfile.encoding=UTF-8")
args.Add("-Dbridge=true")
'<<<<<The following block is what I've edited:
Dim JavaVersion As String = GetSystemProperty("java.version","0.0")
If JavaVersion.StartsWith("1.8") Then
args.AddAll(Array As String("-jar", FileName))
Else
args.AddAll(Array As String("--module-path", File.Combine(GetSystemProperty("java.home", ""), "javafx\lib"), "--add-modules", "javafx.controls,javafx.fxml", "-jar", FileName))
End If
'<<<<<
If currentArguments <> Null Then args.AddAll(currentArguments)
currentArguments = Null
shl.Initialize("shl", javaExe, args)
shl.WorkingDirectory = jarsFolder
shl.RunWithOutputEvents(-1)
'shl.Run(-1)
DeleteOldJars(FileName)
End Sub
It works for me, but maybe needs more polishing?
In any case, this B4j-bridge is a great tool, thank you!
edit: changed the title