B4J Question Linux Standalone Server Apps (non-ui)

Jmu5667

Well-Known Member
Licensed User
Longtime User
Hello

I currently has some server apps that are built using the standalone packager. The real benefit for my organisation is that if we decide to move from Java19 to Java25 it is very easy to do and causes little effort in updating our bank of servers with the new version of the app. Currently the default platform is windows.

I would like to try this on Linux. My Linux is moderate so I am looking for a very simple guide as to how to do this. My objective is to be able to create a standalone shippable version of a server app that runs on Linux.

BTW, I have searched the forum extensively for this, but here I am.

Regards

John.
 

hatzisn

Expert
Licensed User
Longtime User
In linux you have the benefit of Docker. You can create a docker image which is shippable and works directly as it is (no need for standalone). See my signature (in my contributions) on how to create a docker image of a webapp server. Please note that when I created this I was learning docker and cybersecurity wise it is way far behind than best practices of current level of cybersecurity. (B4J Tutorials)
 
Upvote 0

teddybear

Well-Known Member
Licensed User
On Linux, it is no different from Windows.the standalone packager is under the folder build, on Windows, the app is launched using yourapp.exe,while on Linux, you can launch it using the shell command `run.command`
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
In short, you don't actually need to build a standalone package for non-UI server app. I normally just upload the result.jar and www folder.
I have shared some tutorials for publishing server app. Let me check if I can find one.

Here is one:
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
In short, you don't actually need to build a standalone package for non-UI server app. I normally just upload the result.jar and www folder.
I have shared some tutorials for publishing server app. Let me check if I can find one.

Here is one:
I dont want to have to install java on the linux machine, I want to do what I do on windows. On windows I dont install Java. This allow be deploy updated version of the software that can use later versions of Java. Does this make sence to you.
 
Upvote 0

Jmu5667

Well-Known Member
Licensed User
Longtime User
On Linux, it is no different from Windows.the standalone packager is under the folder build, on Windows, the app is launched using yourapp.exe,while on Linux, you can launch it using the shell command `run.command`
Can you give me an example of the run.command you speak of, AFAIK I cant run the exe on linux. I thought we had to build on linux for a linux runtime, and the standalone is built for window only ?
 
Upvote 0

teddybear

Well-Known Member
Licensed User
Can you give me an example of the run.command you speak of, AFAIK I cant run the exe on linux. I thought we had to build on linux for a linux runtime, and the standalone is built for window only ?
See B4JPackger11, it is a B4J non-ui program that builds a package with your app jar and an embedded modularized Java runtime.
Running it on linux, it will generate the run.command and Java runtime under temp/build folder. you can package all the files under the build to distribute it
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Like @teddybear mentioned, we can execute the run.command inside temp/build folder.

1. Compile your project. You get a project_name.jar inside \Objects folder.
2. You need to copy the jar to Linux. One of the ways I always use is to copy it is using B4J Bridge.
Note: b4j-bridge.jar can be downloaded from B4X forum inside Linux using a web browser
3. On Linux, run command: java -jar b4j-bridge.jar (e.g I put b4j-bridge.jar in /home/aeric)
4. Get the IPv4 address of the Linux machine from the logs and use B4J IDE to connect to it.
5. From B4J menu B4J Bridge, click File Explorer. Copy the project_name.jar to the opened Windows.
6. On Linux, you can open /tempjars to find the jar file (e.g /home/aeric/tempjars). If you use Files (or Linux File Explorer, it will only shows Home)
7. I create a new folder and copy the jar file into this folder. e.g /home/aeric/MCP as show below as Home / MCP
8. Besides the jar file, we also need to create a packager.json file with the InputJar value using a text editor.
9. Use Linux terminal, change directory into my MCP folder.
10. Run B4JPackager11.jar with the packager.json file name as an argument with command: java -jar <path-to-B4JPackager11.jar> packager.json
Note: I have my B4JPackager11.jar located inside home folder (i.e 1-level up from MCP folder)
B4JPackager11.jar can also be copy like the method above from B4J installation.
11. After finished building, we can now run the app by running command:
cd temp/build/
sh run.command


Debian
 
Upvote 0
Top