B4J Tutorial The easy way to install your B4J application on Linux

This is meant to be a tutorial for you to easily distribute your applications developed in linux.
Through B4JPackager11 and B4JPackager v1.50 the excellent tool developed by Erel gives us the possibility of obtaining a convenient installation file using install Inno Setup. This is for the Windows world.
Unfortunately, there is not much for Linux as installers.
By sending two files to the customer, even the person who has no experience with Linux will be able to install your program easily and without any problems.

1. Create the package through B4JPackager11 (https://www.b4x.com/android/forum/t...the-simplest-way-to-distribute-ui-apps.99835/).
You will get a directory (build) with all the necessary files.

ubuntu1.jpg


2. Preparation of the nameprogram.desktop file
The script will contain the following lines:
Bash:
[Desktop Entry]
Version=1.0
Name=TRADING
Comment=TRADING
Exec=/usr/TESTLINUX2/build/run.command
Icon=/usr/TESTLINUX2/build/devil-icon.ico
Terminal=false
Type=Application
where the Exec and Icon line contain the path of where you are going to install the program.

3. Preparation of the install_trading.sh file
Bash:
#Install
echo "To install, enter the password."
sudo mkdir /usr/TESTLINUX2
sudo unzip -o app_devil_trading.zip -d /usr/TESTLINUX2
unzip -o app_devil_trading.zip "nameprogram.desktop" -d $HOME/Scrivania nameprogram.desktop
clear
#Delete install files
echo "Installation Complete !!"
echo "1. Select the testlinux_trading.desktop file and click the right mouse button"
echo "2. Select 'Allow execution'"
echo "Good job"
echo "We remain at your disposal"
echo "Email: [email protected]"
echo "Press enter to exit ..."
read text
cd ..
rm -r Software_DevilApp

this will be one of the files that will be distributed, the client running this file will install your system on linux

4. Preparing the prepare_install.sh file
The script will contain the following lines:
Bash:
#Devil-App
#File autoinstall Format zip
#Zip Folder build
cd /home/devil/Scrivania/B4JPackager11/Objects/temp
zip -r /home/devil/Scrivania/B4JPackager11/Objects/app_devil_trading.zip build/
cd ..
zip app_devil_trading.zip nameprogram.desktop
cp app_devil_trading.zip Software_DevilApp
cp install_trading.sh Software_DevilApp
#End compress

The file zips the Build directory and adds the nameprogram.desktop file to the zip file.
Once this is done, copy the 2 files that you are going to distribute (app_devil_trading.zip + install_trading.sh) into the "Software_DevilApp" folder.
So what you are going to distribute is contained in the "Software_DevilApp" folder.
After sending the folder with the content, the customer will simply have to click on the install_trading.sh file and it will be installed automatically by creating an icon on the linux desktopo and deleting the superfluous files at the end of the installation, as in the following video:



Thats all.
Have a nice new year 2020 šŸ„³šŸ„³šŸ„³
** The system has been tested on Ubuntu and Mint **
Bye
Marco
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Nice this I have to use this.
Thanks
 

Bernard Berger

Member
Licensed User
Hi Marco,
Many thanks for the tutorial.

I'm still struggling to launch my application under Linux though ..

While I understand the tutorial and its purpose, I'm missing the key element which is "run.command", as per you desktop launcher file:

[Desktop Entry]
...
Exec=/my path here/run.command
...

Would you mind elaborate on the content of run.command please ?

A big thank you in advance for your answer,
Bernard
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Marco,
Many thanks for the tutorial.

I'm still struggling to launch my application under Linux though ..

While I understand the tutorial and its purpose, I'm missing the key element which is "run.command", as per you desktop launcher file:

[Desktop Entry]
...
Exec=/my path here/run.command
...

Would you mind elaborate on the content of run.command please ?

A big thank you in advance for your answer,
Bernard

Very simple as you see in point 1 of the main thread, after having created the package through B4JPackager11 you will also find the run.command file in the folder BUILD
 

Bernard Berger

Member
Licensed User
Then I must be doing something wrong ..
Using either the built-in packager or the external B4JPackager v11, I do indeed get the same directory structure as the one shown by your own picture.


View attachment 138992
But, in my case run.command is nowhere to be found in that structure.

This is a picture of the Build directory
Build.png


And run.command is not in the Build directory or any other sub directories ..

For your information, I'm new to B4J and to Java.
I have developped an application which runs perfectly fine under Windows (launching the exe or the bat file).

But to lauch this same application (the jar file) under Linux, as I said. I'm strugling (mostly because of the "no JavaFX" error).

And it looks like run.command would hold the way to launch the application ... but it is not created by the packager ...

So, beeing new to B4J, may be I'm missing a step in the packaging process that is required to generate run.command ...

Any further help will be greatly appreciated :)
 

MarcoRome

Expert
Licensed User
Longtime User
Then I must be doing something wrong ..
Using either the built-in packager or the external B4JPackager v11, I do indeed get the same directory structure as the one shown by your own picture.


View attachment 138992
But, in my case run.command is nowhere to be found in that structure.

This is a picture of the Build directory
View attachment 138994

And run.command is not in the Build directory or any other sub directories ..

For your information, I'm new to B4J and to Java.
I have developped an application which runs perfectly fine under Windows (launching the exe or the bat file).

But to lauch this same application (the jar file) under Linux, as I said. I'm strugling (mostly because of the "no JavaFX" error).

And it looks like run.command would hold the way to launch the application ... but it is not created by the packager ...

So, beeing new to B4J, may be I'm missing a step in the packaging process that is required to generate run.command ...

Any further help will be greatly appreciated :)

B4JPackager11 must compile on linux ( not windows ).
After doing this in the folder you will also find the run.command file

See also:
 

Bernard Berger

Member
Licensed User
Hi Marco
Many thanks for your answer. It is very helpful indeed.

Now, if you do not mind, I need to ask another question:

Are you saying

.. that anyway (with or without the need for run.command), if I want to launch the application under Linux , I need to package it under Linux ?

or

.. I can use the Jar file created at compile time under windows and using the appropriate way (yet to be found somewhere in the forum), I will be able to launch it under Linux ?

Again, many thanks for your time and patience !
 

MarcoRome

Expert
Licensed User
Longtime User
Hi Marco
Many thanks for your answer. It is very helpful indeed.

Now, if you do not mind, I need to ask another question:

Are you saying

.. that anyway (with or without the need for run.command), if I want to launch the application under Linux , I need to package it under Linux ?

or

.. I can use the Jar file created at compile time under windows and using the appropriate way (yet to be found somewhere in the forum), I will be able to launch it under Linux ?

Again, many thanks for your time and patience !

1. If you want to follow this tutorial you will need to create the package under linux
2. You can run the jar file without problems if you have the java environment installed on the target machine
 
Top