B4x rant thread

I read the posts that Erel and others pointed to, but it’s not enough. I searched the B4X forum and couldn’t find any complete and working solution for building the “standalone” for macOS.

But I was able to pull together different pieces and got it working like this:

  1. Download OpenJDK as Erel cited above and unzip this to anywhere on your Mac. You will be running the java executable found in the bin folder from a terminal, so making it an easy path is recommended.
  2. Build the standalone app in B4J on Windows. This step is needed to create the jar and json files (couldn’t figure out a way to create these files without doing the full Windows standalone build).
  3. From the resulting Objects folder (parent of the temp/build folder that was just created), copy the <appname>.jar and packager.json files to a folder on the Mac (should use a separate folder because the build process to follow will overwrite the Windows build)
  4. Also copy the B4JPackager11.jar file from your Windows installation of B4J (Program Files (x86)\Anywhere Software\B4J).
  5. Modify the packager.json file to reflect the correct location of the jar file (just remove the entire path if you copied the jar file as directed in step 3).
  6. In a terminal window, change to this folder, then run:
    <../..>/bin/java -jar B4JPackager11.jar packager.json (replacing <…/…> with the path to the OpenJDK bin folder unzipped in step 1.
  7. This should result in a temp/build folder. This build folder contains everything to run the app on macOS. To run it you have to execute the run.command script from Terminal.

For rebuilding, only copy the jar file (after building the Windows package) and rerun step 6.

Still to do: Figure out how to “package” this build folder into a proper macOS app, and one that doesn’t leave a separate Terminal window behind (there’s talk on the forum of possible ways to accomplish this).

Note that you can add other things to the packager.json file. Some of the options I’ve seen look like this:

    {
    "IncludedModules": "javafx.web",
    "IconFile": "myicon.ico",
    "InputJar": "yourapp.jar"
    }
2 Likes

Thank J. Got it working now…

a simple hello world create 182MB file but when i include a ico file, it goes down to 134MB but when i double click on the run.command, it does not show the ico on the dock.

i manage to change the run.command to HelloWorld.command

a quick question, what libabry should i use to connect sqlite??

You have to use the search function in the B4X forum: https://www.b4x.com/android/forum/pages/results/?query=sqlite

And look for a post with the prefix Tutorial

FWIW:
I downloaded B4j today. I’m on Win10. Hello World exe generated is 93KB.

About the B4J Mac packages, I’ve just created one as an example.
https://www.b4x.com/b4j/files/MacAngryBirdsExample.zip (35mb)

You can run it by unzipping the package and clicking on run.command. As I previously wrote there is place for improvement here and this is not the case with Windows packages (which are simpler to create and include an executable).

Creating it is done with:

  • Run the project locally (on Windows) to generate the compiled jar. It will be in the Objects folder. Copy it to the Mac.
  • Connect with B4J-Bridge to the mac. You need to run B4J-Bridge with Java 11+ downloaded from the link I posted above:
jdk-14.0.1/Contents/Home/bin/java -jar b4j-bridge.jar 

Open B4J-Packager11 in the IDE and set the InputJar parameter. In most cases you don’t need the json file.

Private InputJar As String = "/users/username/Downloads/AngryBirds.jar"

Run it and the package will be created on the Mac. You need to distribute all the files under the build folder.

1 Like

@Erel, how come the exe is small???

The size of a standalone Windows package is also about 35mb (or 50mb if using WebView).

The exe file itself is small but it depends on the other files.

@Erel,
try doing the jave -jar on any jar file and i got the error on JavaFX component.
i check the javafx component in the folder and it is there.
i even try 14.0.2 which has javafx component

B4J-Bridge is a non-ui app so it can run with java -jar.

UI apps depend on additional components and should be distributed as explained above (it is also possible to distribute them in other cases, this should be discussed in B4X forum).

i know… i was doing just that… java -jar on terminal.
i read everything on the forum for the error message and try everything without success.

sorry… got it working now here is what shown in the terminal. i assume i need to put 25.45.79.3 for the bridge on the IDE

B4J-Bridge v1.40
Running on Java 11+

JavaFX modules: javafx.fxml,javafx.swt,javafx.media,javafx.graphics,javafx.swing,javafx.web,javafx.controls,javafx.base

External JavaFX path: /Library/Java/JavaVirtualMachines/jdk-14.0.2.jdk/Contents/Home/javafx/lib

Waiting for connections (port=6790)…

My IP address is: 25.45.79.3

FTP Server started: ftp://25.45.79.3:6781

Start B4J-Bridge with -disableftp to disable.

Welcome Jurgen !

1 Like

Thanks

1 Like

This does not work, as I mentioned in my step-by-step post. I just tried it again on another Windows 10 computer to make sure it wasn’t an issue with my VM. The only option I found that produced the compiled jar file is to run “Build Standalone Package” on Windows.

Update:
So I tried to move the exe somewhere else and it wouldn’t run. Then I moved the entire build folder somewhere else and it ran. The build folder is about 48 MBs on my machine. Not sure if all the folders/files therein are needed or not.

You did compile in Release mode? That is when the .jar is generated in the Objects folder on Windows

image

1 Like

Ah, that’s it. Thanks.

Again, as I stated in my step-by-step post, there’s not a complete and working procedure anywhere that I could find. This is one more detail to add.

Edit: This creates the jar file, but not the json file. If you’re going to build the Mac package from Terminal, you’ll need this (or just create it - format is included in my post above). If you are going to use the remote-debug method that Erel laid out, then you don’t need the json file.

mine did create the json file next to the jar file but what is inside is the path for the windows machine.

Couple of weeks dabbling with B4A and in some areas Im impressed.
But currently I think Im running into possible memory issues under Android. I have a couple of million element int arrays which represent something like a map, and when that ‘map’ is fully populated the tablet slows to a crawl / doesn’t refresh the screen
Working on optimising it but I have feeling it may not scale as I would like.
This isnt a rant, and may be due to inexperience.