B4J Question Integrated B4JPackager11

rfresh

Well-Known Member
Licensed User
Longtime User
When I start to run the Build Standalone Package, I get an error Java11+ is required. I just installed JDK 11.0.9

Do I have to update a path in B4J?

Thank you...
 

bdunkleysmith

Active Member
Licensed User
Longtime User
I believe you will find you must use the version of Java 11 from the download link on the Installation instruction page of B4J because you will see it says "Note that other versions of Java 11+, not downloaded from B4X, will not work as JavaFX will be missing."

But yes, you will also have to update the javac.exe path as per the Install and configure B4J section on the Installation instruction page.
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
This B4JPackager11 is only meant to run on windows correct?

I read about the " IconFile - Path to the executable icon file (.ico file)" but exactly where do I set the path?
 
Last edited:
Upvote 0

bdunkleysmith

Active Member
Licensed User
Longtime User
I read about the " IconFile - Path to the executable icon file (.ico file)" but exactly where do I set the path?


In this post Integrated B4JPackager11 - The simple way to distribute standalone UI apps you will see it says:

The packager supports all kinds of settings. You can set them with the new #PackagerProperty attribute.

For example to set the icon file, assuming that the ico file is in the Files tab and is named turtle.ico:

B4X:
#PackagerProperty: IconFile = ..\Files\turtle.ico
 
Upvote 0

rfresh

Well-Known Member
Licensed User
Longtime User
I see. Thank you.

I can build the stand alone program now and it works under windows. However, when I do a normal release build in B4J, when I go to double click on that jar file, it doesn't display. I see no flicker of it starting up, nothing. How do I get that compile capability back?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
when I go to double click on that jar file, it doesn't display
That's why you need the packager with Java 11. Unlike Java 8, which is installed with an installer, Java 11 is a copy install. When Java 8 is installed javaw.exe is associated with .jar files and some paths are set in the environment variables so clicking on a Java 8 jar opens it. This does not work for Java 11 so you need the packager to make a standalone runnable program.

You could alternatively run a Java 11 jar with a batch file with the correct magic invocations or I use a Basic4ppc program with the exe renamed to the same name as the jar with a preset environment variable OpenJdkPath set to the folder where Java 11 is installed.

B4X:
Sub Globals
    'Declare any global variables here
    Dim appargsfile
    appargsfile = args(0) & ".args"
    Dim ThisVersion : ThisVersion = "4.0"
End Sub

Sub App_Start
    Obj1.New1
    Obj1.CreateNew("System.Environment")
    envar = "OpenJdkPath"
    ojp = Obj1.RunMethod2("GetEnvironmentVariable", envar, "System.String")
    If ojp = cNull Then
        Msgbox("Environment variable '" & envar & "' not present!", "OpenJDK Path Error")
    Else
        appargs = ""
        javaops = ""
        debug = EOF
        If FileExist(appargsfile) Then
            FileOpen(in, appargsfile, cRead)
            appargs = FileRead(in)
            javaops = FileRead(in)
            debug = FileRead(in)
            If javaops = EOF Then
                javaops = ""
            End If
            FileClose(in)
        End If
        If ArrayLen(args()) > 1 Then
            For j = 1 To  ArrayLen(args()) - 1
                If StrIndexOf(args(j), " ", 0) > 0 Then
                    appargs = appargs & " " & Chr(34) & args(j) & Chr(34)
                Else
                    appargs = appargs & " " & args(j)
                End If
            Next
        End If      
        ' java options
        shellargs =  " --module-path " & ojp & "\javafx\lib --add-modules ALL-MODULE-PATH " & javaops & " "
        ' jar file
        shellargs = shellargs & "-jar " & Chr(34) & AppPath & "\" & args(0) & ".jar" & Chr(34)
        ' app arguments
        shellargs = shellargs & " " & appargs
        Shell(ojp & "\bin\javaw", shellargs)
        If debug <> EOF Then
            Msgbox("Runner Version "  & ThisVersion & CRLF & CRLF &  shellargs, "Shell Arguments")
        End If
    End If
End Sub
 
Upvote 0
Top