B4J Tutorial UI apps packaging - self contained installers

Status
Not open for further replies.
It is recommended to use B4JPackager11: Integrated B4JPackager11 - The simple way to distribute standalone UI apps

B4J Packager is a small utility that uses javapackager to create a single file installer for Mac or Windows, that includes the app files and the Java runtime.

This means that from the end user perspective your app doesn't depend on any additional runtime. It makes deployments very simple.
The installer size will be around 40mb as it includes the JRE.

SS-2015-08-02_17.14.48.png


The Windows installer (exe) is built on a Windows computer and the Mac installer (dmg) is built on a Mac computer.
You need to install Inno Setup on the Windows computer: http://www.jrsoftware.org/isinfo.php

You can either run the attached source code from the IDE or download the jar file: www.b4x.com/b4j/files/B4JPackager.jar

The source code depends on the following additional libraries: Archiver (B4A library) and jControlFX

Using this tool is quite simple. First you need to set the path to javapackager.
On Windows the path will be similar to:
C:\Program Files\Java\jdk1.8.0_51\bin\javapackager.exe
On Mac:
/Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home/bin/javapackager

Compile your app in release mode and then set the path to the Jar file and fill the other fields.
The icon on Windows is an ico file and on Mac is an icns file.

Click on the Build button. The building process can take a minute or two.
The installer will be created under the bundles folder (the folder will be opened).

Notes & tips:

1. Make sure to test your app after it is installed. It will be installed under Program Files.
Program Files is a read-only folder. Any attempt to write to File.DirApp will fail (you should use File.DirData instead).

2. javapackager documentation:
Windows - https://docs.oracle.com/javase/8/docs/technotes/tools/windows/javapackager.html#BGBIJBHF
Linux / Mac - https://docs.oracle.com/javase/8/docs/technotes/tools/unix/javapackager.html

3. It is recommended to run the packager from the IDE (at least in the beginning) as it prints important information in the logs.
You can also run it from the command line with: java -jar B4JPackager.jar
4. The installers will use the app package name to identify the app. Make sure to change it from the default value. Otherwise all applications will be installed in the same folder.
5. Java 9 is currently not supported. Make sure that both B4J and the path to javapackager point to Java 8.
6. If running on a Mac then you probably should change the package to pkg. See this discussion: https://www.b4x.com/android/forum/t...staller-dmg-failed-to-produce-a-bundle.87897/

Change log:

v1.50

- Adds support for newer versions of Java 8.
- javapackager is run in verbose mode.
- The logs are updated while the process is running.
 

Attachments

  • B4J Packager.zip
    4.7 KB · Views: 2,519
Last edited:

alienhunter

Active Member
Licensed User
Longtime User
Hi
is there a way to update the java component ? example you original deployed with 8_40 now you need to update the installation with 8_60 java without running a new setup
 

Firpas

Active Member
Licensed User
Longtime User
Hi to everybody:

Here is my cuestión:

How create a shortcut as part of the installation?

Thanks in advance
 

Firpas

Active Member
Licensed User
Longtime User
Thanks Erel

Only one question more ...

How can i add an editor/autor name??
 

welu1805

Active Member
Licensed User
Longtime User
Hi Erel, I get the following error:

App identifier: de.wedersoft.MusicBookTransfer.main
Success: true
StdOut: Using base JDK at: D:\Program Files\Java\jdk1.8.0_45\jre
StdErr: java.io.IOException: Exec failed with code 2 command [[D:\Programme\Inno Setup 5\iscc.exe, /oD:\Users\Lutz\AppData\Roaming\B4JPackager\bundles, D:\Users\Lutz\AppData\Local\Temp\fxbundler1569188900774224640\images\win-exe.image\MusicBookTransfer.iss] in D:\Users\Lutz\AppData\Local\Temp\fxbundler1569188900774224640\images\win-exe.image
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:165)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:138)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:132)
at com.oracle.tools.packager.windows.WinExeBundler.buildEXE(WinExeBundler.java:680)
at com.oracle.tools.packager.windows.WinExeBundler.bundle(WinExeBundler.java:356)
at com.oracle.tools.packager.windows.WinExeBundler.execute(WinExeBundler.java:172)
at com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:506)
at com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:471)
at com.sun.javafx.tools.packager.Main.main(Main.java:474)
Error: Bundler "EXE Installer" (exe) failed to produce a bundle.
ExitCode: -1

What is wrong? (Win 10, Inno Setup 5 is installed)

Thanks
Lutz
 

welu1805

Active Member
Licensed User
Longtime User
Now I run B4J as administrator:

Program started.
App identifier: de.wedersoft.MusicBookTransfer.main
Success: true
StdOut: Using base JDK at: D:\Program Files\Java\jdk1.8.0_45\jre
StdErr: java.io.IOException: Exec failed with code 2 command [[D:\Programme\Inno Setup 5\iscc.exe, /oD:\Users\Lutz\AppData\Roaming\B4JPackager\bundles, D:\Users\Lutz\AppData\Local\Temp\fxbundler5172231196875092326\images\win-exe.image\MusicBookTransfer.iss] in D:\Users\Lutz\AppData\Local\Temp\fxbundler5172231196875092326\images\win-exe.image
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:165)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:138)
at com.oracle.tools.packager.IOUtils.exec(IOUtils.java:132)
at com.oracle.tools.packager.windows.WinExeBundler.buildEXE(WinExeBundler.java:680)
at com.oracle.tools.packager.windows.WinExeBundler.bundle(WinExeBundler.java:356)
at com.oracle.tools.packager.windows.WinExeBundler.execute(WinExeBundler.java:172)
at com.sun.javafx.tools.packager.PackagerLib.generateNativeBundles(PackagerLib.java:506)
at com.sun.javafx.tools.packager.PackagerLib.generateDeploymentPackages(PackagerLib.java:471)
at com.sun.javafx.tools.packager.Main.main(Main.java:474)
Error: Bundler "EXE Installer" (exe) failed to produce a bundle.
ExitCode: -1
Mär 13, 2016 1:26:19 PM com.sun.javafx.css.StyleConverterImpl getInstance
SEVERE: StyleConverterImpl : converter Class is null for : com.sun.javafx.scene.layout.region.CornerRadiiConverter
Mär 13, 2016 1:26:19 PM com.sun.javafx.css.StyleConverterImpl readBinary
SEVERE: could not deserialize com.sun.javafx.scene.layout.region.CornerRadiiConverter
could not deserialize com.sun.javafx.scene.layout.region.CornerRadiiConverter
 

welu1805

Active Member
Licensed User
Longtime User
The icon file was not correct. It was a renamed png.
Now I have a correct icon file and it works great!
 

Swissmade

Well-Known Member
Licensed User
Longtime User
Hi all
Try to use the Packager but with no result.:(

Inno Setup is installed latest version.
In the log of B4J i get following.

Waiting for debugger to connect...
Program started.
App identifier: tcp.server.main
Success: true
StdOut: Using base JDK at: C:\Program Files\Java\jdk1.8.0_66\jre
Using base JDK at: C:\Program Files\Java\jdk1.8.0_66\jre
Detected [iscc.exe] version 0 but version 5 is required.
Bundler EXE Installer skipped because of a configuration problem: Can not find Inno Setup Compiler (iscc.exe).
Advice to fix: Download Inno Setup 5 or later from http://www.jrsoftware.org and add it to the PATH.
StdErr:
ExitCode: 0


Thanks for any Help.
 

ToolboxZX

Member
Licensed User
Longtime User
Has anyone run into the issue of downloading the Windows example, running the install, and after it installs, when it attempts to run, it errors out with the message "Google Maps Example.exe is not a valid Win32 application." ? I tried to redownload the example, have turned off all anti virus software and still no go. I am testing this on Windows XP.
 

ToolboxZX

Member
Licensed User
Longtime User
It is a 64 bit program. It will not work on Windows 32 bit.

You need to build the installer on a 32 bit computer if you want to create a 32 bit installer.
Thank you Erel that was it :)

Are there any particular arguments that can be added (adjusted) to change the default path the application is installed in?
 
Status
Not open for further replies.
Top