B4J Question Request Architecture/Deployment Suggestions

cjpryor

Active Member
Licensed User
Hi everybody. I am looking for advice on B4J architecture and deployment suggestions for the following scenario. I did search the forums and suspect the answers I am looking for are there but I just haven't found them.

Over 10 years ago I built a java database application using an embedded Derby database. I architected it such that it can be run from a USB flash drive on Windows, Mac, and Linux systems, against the same database, so you can see and update the same data from any desktop computer running Windows, Mac, or Linux. I also developed some complimentary Android apps but that is a different discussion.

I want to create a similar application using B4J and expand it into Android and iOS. I have created a proof of concept (POC) application in B4J with a SQLite database. I went through the base deployment operations for each operating system using B4JPackager11. I now have a way to deploy and run independent copies of my new B4J POC application on Windows, Mac, and Linux. However, I could use some suggestions for options with regard to the following limitations of my current B4J architecture/deployment:
  1. The Windows, Mac, and Linux deployments do not share the same database so each will have it's own copy of the data.
  2. The Windows, Mac, and Linux deployments cannot all be run from the same USB. The way the Linux deployment is working I need to use an NTFS formatted USB drive which is read-only in Macs.
I am not sure how important it is to be able to run the software from the same USB flash drive against the same data on all systems. I have not done any market research to determine how important that is to my customers. I suppose I could just deploy my new B4J application as is and be fine. However, I thought I should at least ask the experts about my options.

Thanks in advance.
 

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
i am not sure how important it is to run all 3 major OS from a single USB drive, sounds more like fancy feature than an useful one, but you may know best.

B4JPackager11 is meant to ease the deployment process but it is not the only one, you could create a basic JAR file and attach a jdk (1 by each OS) in the USB and run it.
java - Running JavaFX application with JDK 11+ - Stack Overflow
Download OpenJDK builds of Liberica JDK, Java 8, 11, Java 16 Linux, Windows, macOS | BellSoft - Java Platform & Applications Experts (bell-sw.com)

Seems convoluted but if that fancies you, again, why not.
 
Upvote 0

cjpryor

Active Member
Licensed User
@enrique - Thank you for your feedback.

I have been marketing the current version of this software to run off of a USB on any operating system for over a decade - the idea of a truly portable program that can be run off of a USB and stored in a secure location when not in use seems to be attractive to my customer base. I also have a retail outlet that sells the software on a USB so it really needs to be able to work on any operating system from that single USB since there is no telling what operating system the customer who purchases the USB will be using.

It is great that I can deploy my B4J program as executable jars with embeded JDKs for each operating system. That is how I deploy my current Java application. What I am not yet clear on is how the B4J code gets converted to jar files and how to properly execute those jar files. That is why I was relying on the B4JPackager11. I tried running the executable jar built by B4J but it would not run on its own (with or without a packaged jdk) - I suspected missing dependencies which (I think) are resolved by the B4JPackager11 scripts. I guess I need to spend more time exploring this B4J executable jar option.

What is probably of less value is all of those deployments for different operating systems sharing the same database since most people are probably not using the software on multiple operating systems. However, it does give people the ability to easily view their collections on other computers (Friends, Family, Clients, etc.) even if others use a different operating system.

From a deployment architecture perspective, in order to allow every version (per OS) on the same USB to share the same database is to keep all of the executables (one per operating system) in the same file structure with the shared database stored in the resources folder of the Apple deployment (.app folder). I suspect I can do the same if I work with the SQL.InitializeSQLLite ... statement in the B4J application but thought it would be good to get feedback from the experts before I start exploring this option.

Thanks again! I appreciate any feedback. If there is not already an answer any hints that could lead down a path to a solution are appreciated!

:)

Clay
 
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Hi Again!

compile jar file in release and find the compile jar in the objects folder (you can do this with any jdk 11, preferably this forum official download)


enter here: Download OpenJDK builds of Liberica JDK, Java 8, 11, Java 16 Linux, Windows, macOS | BellSoft - Java Platform & Applications Experts (bell-sw.com)

download FULL JDK zip (i downloaded windows, but you can download all major platforms)
1619974781673.png


i unziped it in C:\java\ you may want to unzip it in your USB.

now you can run that jar file with this line: (i imagine you can create a BAT file and make the route relative)
C:\java\jdk-11.0.11-full\bin\java -jar yourJar.jar

it will open your JavaFX application.
 
Upvote 0

cjpryor

Active Member
Licensed User
Thank you. I have been using Oracle Open JDK 14.0.1. I will revisit tomorrow and report back. Thanks again.
 
Upvote 0

cjpryor

Active Member
Licensed User
@enrique - I bought you a coffee because I think this approach will work. As it turns out, the dependency issue I was seeing when I tried to run the original jar file was JavaFX. I found the solution on the forums that said to use B4JPackager11 for this very issue so that is why I was using that approach.

Interestingly, when I point the B4J IDE to the Liberica JDK I get an error that javafx.swt is missing so I pointed the B4J IDE back to the Oracle OpenJDK and then ran the compiled jar file against the Liberica JDK as you suggest and it works. This was all in Windows so far. I will go about packaging the Liberica JDKs for deployment for each operating system and see how those deployments go as well.

I do have a couple of follow on questions.

1. Is there a Liberica JRE for packaging with java applications? I can't seem to find just the JRE. I'll keep looking for an answer but figured it wouldn't hurt to ask.

2. Do you know of any issues with building your jar files in B4J using Oracle OpenJDK and running them with a packaged Liberica JDK? I am obviously using the same major.minor versions (in this case 11.0.x) in each. I doubt the patch versions matter (other than having the latest for each) since these are obviously different branches of the same source.

Thanks again!
 
Last edited:
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
I bought you a coffee because I think this approach will work.
thank you very much appreciated!

Is there a Liberica JRE for packaging with java applications?
No, in fact the concept of JRE will not be available anymore even for Oracle, in the future only jdks will be provided.

. Do you know of any issues with building your jar files in B4J using Oracle OpenJDK and running them with a packaged Liberica JDK?
Afaik no for most of all of our b4j centric work, if you happen to use com.sun packages provided by oracle you could be in some problems but usually even oracle advices against the use of it.

I doubt the patch versions matter
thats correct, between oracle jdks you will find a lot of compatilibity between minor versions, it is the same approach.

with liberica jdk you could run jar + javafx files on raspberry pi and other ARM devices
 
Upvote 0

cjpryor

Active Member
Licensed User
@enrique - It has been about 5 years since I have done application development/deployment using java. It is amazing how much I have forgotten let alone how much things have changed since then. For example, as it turns out, I actually deployed an executable (self-contained application) jar file in the past so my customers did not need to use "java -jar app.jar" in my deployments.

I am still reviewing my past deployment notes and revisiting what I need to do to generate an executable jar for this B4J environment. I am assuming that it will be essentially the same process for the jar file generated by the B4J build.

Once again thanks. I appreciate you taking the time to help me with this.

Clay
 
Last edited:
Upvote 0

EnriqueGonzalez

Well-Known Member
Licensed User
Longtime User
Upvote 0

cjpryor

Active Member
Licensed User
most cases, you could create a bat file or sh file to run it.

Yes, I offer that option as well in my current deployments. Usually those files are just ignored. However, they do come in handy if my customers need more memory for the application. The application includes the ability to store and use pictures which can use up a lot of memory if they have a lot of large pictures. On the other hand, most of my customers do not want to install java on their computers or it is too complicated for them so I found it easier and more reliable just to package the java I want them to use with the application.
 
Upvote 0

cjpryor

Active Member
Licensed User
It looks like things have changed quite a bit since I last built a self-contained Java application. This stack overflow article is very enlightening: https://stackoverflow.com/questions...oy-a-javafx-11-desktop-application-with-a-jre

It seems to me that the B4JPackager11 tool is using this latest approach and I won't be able to do any better on my own. The issue I had with running the Linux deployment from a USB had to do with links not working on a USB formatted as FAT32 (FAT as well). I'm not sure yet, but I suspect I will encounter the same issue no matter how I build the required deployment image for this new approach to building self-contained java applications.
 
Upvote 0
Top