B4J Tutorial [B4X] Using/running B4A and/or B4J on 64 bit Linux Mint 20.2 Cinnamon with 64 bit Wine

walt61

Active Member
Licensed User
Longtime User
Hi John,

Several things are wrong with that one (but more in general, please see below too):
- Don't declare a variable called 'Main'; the 'Main' module will still exist as an Activity module
- In Class_Globals, declare 'Public MainPage As B4XMainPage'
- In B4XPage_Created, use 'B4XMainPage = B4XPages.MainPage'
- But actually I don't see the need to declare this variable, just use 'B4XPages.MainPage' wherever you want to reference that page
- I have no idea about the 'zombie' modules, sorry

That said, this one was really off-topic for this thread and should have been posted in the B4A questions forum. Please start new threads there in case you'd have other B4A/B4Xpages-related questions, as people who are active in the B4A forums are not necessarily looking at the B4J ones, and the question wouldn't (and shouldn't) be addressed to one user. It will also help others to find solutions to their questions in the appropriate forums
 

johnaaronrose

Active Member
Licensed User
Longtime User
Hi Walt,
Your idea didn't work: it gave a compile error. I tried some modifications to it without success. I eventually did in each module where I wanted to refer to the B4XMainPage:
B4X:
Dim MainPage As B4XMainPage
in Class_Globals
and
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("choose")  
    MainPage = B4XPages.GetPage("B4XMainPage")
Then I was able to use MainPage successfully (at least as far as the compiler is concerned) in the module.
I prefer to do this method rather than the amended one you suggested since using B4XPages.GetPage("B4XMainPage"), each time a reference is required, is rather long winded, and since B4XPages.B4XMainPage generates a compile error.
I take your point about my post being off-topic for this thread and have created a new topic for the possible bugs re remove a module at https://www.b4x.com/android/forum/threads/possible-bug-s-when-removing-a-module.138231/
 
Last edited:

TheJinJ

Active Member
Licensed User
Longtime User
Excellent tutorial, thanks!

If you run across the error relating to GLXBadFBConfig when running B4A or B4J, run this in the command line

export MESA_GL_VERSION_OVERRIDE=4.5

Error detail here

Could set this in bashrc or /etc/environment but it causes issues with Chrome which doesn't like that version of GL.

Set the command of the desktop icon
env MESA_GL_VERSION_OVERRIDE=4.5 WINEPREFIX="/home/[USER]/virtualwinedrives/b4x64" wine C:\\users\\Public\\Desktop\\B4J.lnk
 
Last edited:

johnaaronrose

Active Member
Licensed User
Longtime User
@walt61 I've now decided to use B4J for initial development of an Android app as recommended in the B4XPages booklet. All Ok in your tutorial up to step 21. I've downloaded B4JPackager11 from https://www.b4x.com/android/forum/t...the-simplest-way-to-distribute-ui-apps.99835/ Ok. But your step 21 says to compile it. AFAIK that website doesn't give explicit instructions on how to do this. I'm not a java person, so please pardon my ignorance. How should it be compiled in order to create B4JPackager11.jar? I tried using B4J to compile B4JPackager11.b4j but it gave an error on line 152, presumably "File.Copy(InputJar, "", TempFolder, "jar.jar")" :

B4X:
Waiting for debugger to connect...
Program started.
B4JPackager11 Version 1.21
Exe name: B4R_Serial_Connector.exe
InputJar: C:\Users\H\Downloads\projects\B4R_Serial_Connector\Objects\B4R_Serial_Connector.jar
Error occurred on line: 152 (Main)
java.io.FileNotFoundException: C:\Users\H\Downloads\projects\B4R_Serial_Connector\Objects\B4R_Serial_Connector.jar (Path not found)

Could you also tell me what Linuxify does as I must have missed that in your tutorial?

PS I've also had the freeze problem using B4A with my Ryzen desktop. I also didn't see the "PS Idle Control' from within the AMD Megatrends BIOS screens. Crossed fingers!
 

Attachments

  • B4JPackager11Log.txt
    1.9 KB · Views: 311
Last edited:

walt61

Active Member
Licensed User
Longtime User
Hi @johnaaronrose , that's a run-time error, not a compiler error: the compilation went fine (otherwise there would be a second window with the compiler errors) and then B4J runs the jar. The program needs to be fed certain command line arguments which aren't there (because B4J just runs it 'as is') and that's the error you're seeing. You'll find B4JPackager11.jar in the Objects subdirectory of your B4JPackager11 project directory.

Regarding Linuxify: check out section 'Compiling and running your programs': it describes how to run the B4X programs on Linux. Linuxify helps by automating several of these actions so they become just a couple of clicks
 

johnaaronrose

Active Member
Licensed User
Longtime User
@walt61 should have mentioned that I already checked all folders & sub-folders within my B4JPackager11 project directory for the B4JPackager.jar file. Am I correct in stating that the B4JPackager11.jar file is always the same for any user? If so, could you reply with an attachment of the B4JPackager11.jar file?
 

johnaaronrose

Active Member
Licensed User
Longtime User
@walt61 Thanks for that B4JPackager11.jar which I downloaded & copied to my B4X directory. Now having a problem with compile & run of CopyFilesForLinuxify as per attached Log:
B4X:
Expected 3 or 4 arguments, not 0: Linux_top_directory_for_B4J_projects jarname_without_extension delete_temp_folder_Y_or_N [icon_file_path]
Again, there is no .jar file or packager.json file. Any ideas?
 

Attachments

  • B4JCopyFilesForLinuxifyLog.txt
    193 bytes · Views: 302

johnaaronrose

Active Member
Licensed User
Longtime User
It doesn't show up. I think that the problem is that the line for "alias b4jpkg" in .bashrc wants the packager.json file and I haven't got that file. Could you send me the file?
 

johnaaronrose

Active Member
Licensed User
Longtime User
Yo
Got it; just thought of this and your txt file attachment confirms it: you're compiling in debug mode. Compile in release mode and you'll see the jar.
You were correct about changing B4J from Debug to Release mode.
In step 1 of '**** A semi-automated way to get your B4J UI programs ready ****', B4J Compile&Run of CopyFilesForLinux project also needs Release mode to create CopyFilesForLinux.jar file. However, no packager.json file created then. So I did step1 of '*** Compiling and running your programs ***' which created packager.json. However, when I look at that file, it seems very short. I've shown it below. If it looks longer than mine, could you send it to me.
B4X:
{
  "InputJar": "Z:\\home\\john\\Documents\\B4XProjects\\CopyFilesForLinuxify\\Objects\\CopyFilesForLinuxify.jar"
}
 
Last edited:

walt61

Active Member
Licensed User
Longtime User
CopyFilesForLinuxify itself doesn't need a 'packager.json', it only needs the jar as there's no need for packaging that program since it doesn't make sense to run it standalone (it's only useful in a #CustomBuildAction). Notice that 'packager.json' is created when you use menu Project -> Build Standalone Package, not when just compiling.
 

johnaaronrose

Active Member
Licensed User
Longtime User
I seem to be going backwards. I've now installed the B4J stuff. But when I try to a B3A Compile&Run, all my projects compile without errors but on installation to my phone:
B4X:
Signing package file (private key).    (1.19s)
Installing file to device.    Error
adb.exe F 02-25 10:15:29   261   262 sysdeps_win32.cpp:2743] _wenviron is not set, did you link with -municode?

Here's details re adb:

B4X:
john@desktop:~$ adb version
Android Debug Bridge version 1.0.40
Version 28.0.2-5303910
Installed as /home/john/B4X/platform-tools/adb
john@desktop:~$ alias
alias adb='/home/john/B4X/platform-tools/adb'
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
alias b4jpkg='/home/john/B4X/java/jdk-11.0.1/bin/java -jar /home/john/B4X/B4JPackager11.jar packager.json'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias grep='grep --color=auto'
alias l='ls -CF'
alias la='ls -A'
alias ll='ls -alF'
alias ls='ls --color=auto'
john@desktop:~$ cat .bashrc|tail
# Start the Linux version of adb by just typing 'adb'
alias adb='/home/john/B4X/platform-tools/adb'

# Start the Linux B4Jpackager by just typing 'b4jpkg'
# Note: this assumes that 'packager.json' is present in the current working directory and was properly edited
alias b4jpkg='/home/john/B4X/java/jdk-11.0.1/bin/java -jar /home/john/B4X/B4JPackager11.jar packager.json'

# Ensure CustomBuildActions will recognise '%windir%'
export windir="c:\windows"

john@desktop:~$
 
Last edited:

walt61

Active Member
Licensed User
Longtime User
Did you install BOTH adb versions (the Linux and Windows ones) as per steps 24 AND 25? You can also test whether adb is working as expected as described in step 30.

Failing that, perhaps someone else can/will chime in, but the only place I've seen that error is where the adb version is being mentioned. What I would do (and that's really the only comment I can offer) is see if there are any other files called 'adb' on your system (besides the 2 expected ones), rename them, and try again, to make sure that B4A is indeed using version 1.0.40 (and, if not, would after the renames report something like 'can't find adb' or so)?
 

Ivan Aldaz

Member
Licensed User
Longtime User
Hi

First things first: thanks @walt61 and @Mihai Rainer Jr. for your work.

At last I've managed to install and run B4A on Linux, with your tutorial, but there's one thing I need in my app that I couldn't make it work with #CustomBuildAction: B4A Localizator. No problem on Windows, of course, but on Linux no matter the thousand ways I've tried. Then I thought I could try doing something like you did in the "Android SDK Manager" section, but adapting it to B4A Localizator, and... incredibly.... I got it!

(pay attention to the length of the 4th line, and remember to write \\\\ instead of \ in the paths)

B4ALocalizator.desktop:
#!/usr/bin/env xdg-open

[Desktop Entry]
Name=B4ALocalizator
Exec=env WINEPREFIX="/home/YOUR_USER_NAME/virtualwinedrives/b4x64" wine C:\\\\windows\\\\command\\\\start.exe /Unix ./java.exe -Xmx1G -Dprism.order=j2d --module-path ../javafx/lib/ --add-modules=javafx.fxml,javafx.controls -jar c:\\\\B4XLOCALIZATOR-CONVERTER_FILE_PATH\\\\B4XLocalizator-converterXLSXtoDB.jar C:\\\\YOUR_LANGUAGES.XLSX_FILE_PATH\\\\languages.xlsx C:\\\\YOUR_B4APROJECT_FILES_PATH\\\\languages.db
Type=Application
StartupNotify=true
Path=/home/YOUR_USER_NAME/virtualwinedrives/b4x64/drive_c/java/jdk-11.0.1/bin
Icon=4732_B4A.0
Name[es_ES]=B4ALocalizator

Create an empty document by right clicking somewhere on the desktop, copy and paste this text, writing the correct paths to your files, and name it adding ".desktop" extension

I recommend to put the file or a shortcut to it in the desktop, to make it easier and faster to run everytime the file changes

I think this method can also be used to make Robocopy work on Linux, and tried to do it in serveral ways, but no luck. Perhaps somebody with better skills than me (not difficult ?) can do it...

Best regards
 

Ivan Aldaz

Member
Licensed User
Longtime User
I copied the Robocopy.exe file from the "c:/Windows/System32" folder in Windows installation to the ".../virtualwinedrives/b4x64/drive_c/windows/system32" directory in Linux. I thought this could be enough, but seems not...
 
Last edited:
Cookies are required to use this site. You must accept them to continue using the site. Learn more…