B4J Question Package for Linux desktop

aeric

Expert
Licensed User
Longtime User
Anyone has built any distributable desktop package for Linux desktop from jar or files built by B4JPackager11 ?

For Debian based or Ubuntu, it uses .deb and RedHat uses .rpm and so on.

If yes, can anyone share a tutorial explain in easy way how to accomplish it?
 

aeric

Expert
Licensed User
Longtime User
Anyone tried? I got an error.

1710831766414.png


B4X:
com@debian:~/Documents/deb/build$ sudo dpkg -i test.deb
(Reading database ... 140893 files and directories currently installed.)
Preparing to unpack test.deb ...
Unpacking test (1.0-1) ...
dpkg: error processing archive test.deb (--install):
 trying to overwrite '/usr/share/man/man1/test.1.gz', which is also in package coreutils 9.1-1
Processing triggers for man-db (2.11.2-2) ...
Errors were encountered while processing:
 test.deb
 
Last edited:
Upvote 0

teddybear

Well-Known Member
Licensed User
The test is a linux command which checks file types and compares values. the manual has been existed in directory man1.
For your app, you should give a different name which does not exist in man1
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I tried with jpackage (JDK 14.0.1)

B4X:
jpackage --input /home/aeric/deb/ \
--name "AppName" \
--main-jar AppName.jar \
--main-class com.example.main \
--type deb \
--dest /home/aeric/deb/output

install
B4X:
sudo dpkg -i appname_1.0-1_amd64.deb

the app install to /opt/appname

I still not success.
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
jpackage --input /home/aeric/deb/ \ --name "AppName" \ --main-jar AppName.jar \ --main-class com.example.main \ --type deb \ --dest /home/aeric/deb/output
I have zero experience, as I stated in other thread, in making debs - but I feel this can't be correct...

app install to /opt/appname
...because you don't specify the /opt/ destination at any point. I mean, packages can install things to many different directories, there's nothing magic about /opt/ that makes it the default if not specified.

You might have misunderstood the --dest flag, or perhaps something is missing from the command.

Have to tried this to see what's reported?
B4X:
sudo gdebi-gtk test.deb
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I have zero experience, as I stated in other thread, in making debs - but I feel this can't be correct...


...because you don't specify the /opt/ destination at any point. I mean, packages can install things to many different directories, there's nothing magic about /opt/ that makes it the default if not specified.

You might have misunderstood the --dest flag, or perhaps something is missing from the command.

Have to tried this to see what's reported?
B4X:
sudo gdebi-gtk test.deb
I have edited the directory name.

--dest flag is where the generated deb file is store. It works correctly.

If you check the Oracle documentation, jpackage by default creating the package to be install to opt/appname.

My question is, what is the correct structure to create the package. i.e what launcher files go to /bin, what goes to /lib and so on.
Can we make use of the output from B4JPackager11 (with packager.json) to build the package file?
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
My question is, what is the correct structure to create the package. i.e what launcher files go to /bin, what goes to /lib and so on.
Can we make use of the output from B4JPackager11 (with packager.json) to build the package file?
Sorry, I don't know.

If you're able to share your test.deb, I can take a look at it with gdebi and see if it says anything that might be relevant. Beyond that I don't know that I can be of more help.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I think I have misconfigured javafx in the virtualbox. I will try to fix it and see whether the app will load.

In the mean time, I see inside the /opt/appname the app seems store in a lib path.
B4X:
com@debian:/opt/demoapp/lib/app/bin$ ./java @release_java_modules.txt  -m b4j/b4j.example.main
WARNING: Unknown module: javafx.controls specified to --add-opens
WARNING: Unknown module: javafx.base specified to --add-opens
WARNING: Unknown module: javafx.controls specified to --add-opens
WARNING: Unknown module: javafx.graphics specified to --add-opens
WARNING: Unknown module: javafx.controls specified to --add-opens
WARNING: Unknown module: javafx.graphics specified to --add-opens
WARNING: Unknown module: javafx.graphics specified to --add-opens
WARNING: Unknown module: javafx.controls specified to --add-opens
WARNING: Unknown module: javafx.graphics specified to --add-opens
WARNING: Unknown module: javafx.graphics specified to --add-opens
WARNING: Unknown module: javafx.base specified to --add-opens
WARNING: Unknown module: javafx.graphics specified to --add-opens
WARNING: Unknown module: javafx.graphics specified to --add-opens
WARNING: Unknown module: javafx.base specified to --add-opens
Error: Unable to load main class b4j.example.main in module b4j
    java.lang.NoClassDefFoundError: javafx/application/Application
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
Here is a Hello World B4J app
I opened it with gdebi-gtk, and it doesn't protest at all so as far as I can tell this is a valid package. Running the Lintian test produces numerous error messages, but that's pretty much par for the course, as far as I can tell. For comparison I opened a deb for Apache Netbeans that I happened to have nearby, and it also produces lots and lots of error messages. Installs just fine.

If the problem is related to javafx you could make your test even more basic: Make your Hello World app a console app, so javafx doesn't even come into play.

(I did not try to install your deb. I would have to have a test machine for that, and I don't have one nearby.)
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Currently I am okay with distributing the build folder from B4JPackager11 and take more steps to manually make the app works.

The point is if we have a better way to distribute an installer package in .deb format then it would be great for novice user or support engineer.

It will be more professional to host the deb file and sell the product.
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
I am just started to learn about .deb format.

It has a strict structure. We need to check the compliance using lintian and dpkg tool. Maybe there are difference in deploying non-free package?

There are not much tutorial on the Internet teaching about the process.

Some tutorials just explain about packaging only a simple java class and some use IDE like IntelliJ.

jpackage is still in incubator when added to jdk 14, not sure it is already a stable tool in jdk 17 or 21+.

I haven't tried on java-packager. I am happy if anyone is interested to explore more.
 
Upvote 0

Daestrum

Expert
Licensed User
Longtime User
I did try with the GraalVM native-image, which is supposed to produce a native executable for linux/windows.

It's fair to say, because of reflection in the jar, you end up writing a book (well a json file) on which methods use reflecion, so I gave up.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
jpackage is still in incubator when added to jdk 14, not sure it is already a stable tool in jdk 17 or 21+.
It should be stable now. Have you build your packages first under the Linux system that you are trying to use jpackage on? According to the guide linked in you wish, it states:
Application packages must be built on the target platform. The system used for packaging must contain the application, a JDK, and software needed by the packaging tool.
The B4JPackager source should be somewhere on the forum. You should be able to build it in the target platform, then build your app via it, then use jpackage. And no, I've not done this, just going by what I'm reading (and I may have dabbled with this in the past when jpackage was broken).

Links:
 
Upvote 0

aeric

Expert
Licensed User
Longtime User
Actually I have successfully created the deb file using dpkg.
The problem is many directories are not writable.
The best writable directory is home/USER but I won't know what is the user's directory name.
 
Upvote 0
Top