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:

Douglas Farias

Expert
Licensed User
Longtime User
someone know how to add a option to select a path on the instalation?
classPath=path

how can i set the path if have diferents OS (windows,mac etc)
Some users want to install on driver D:/ for example and the installer dont add this option.
 
I packed my .jar file to .exe
But when I'm trying to install it, most of AntiVirus known it as a virus during installation and don't let it install correctly. How to solve it?
 
The anti virus software suspects any new executable. If you want to avoid it then you need to purchase a certificate and sign it (some anti viruses will still warn about the installer until it is popular enough).
Ok, but what can I do now or anyway to build the executable file not installation file ( to solve the problem ) ?
 

alienhunter

Active Member
Licensed User
Longtime User
Hi Erel,

setting -BsystemWide=false it does not make the installer go to the user home !, otherwise this is great thanks

B4X:
args.AddAll(Array ("-deploy", "-srcFiles", txtJar.Text, "-native", packageExtension, _
            "-BsystemWide=false", "-title", txtTitle.Text, "-name", txtName.Text, "-outdir", workingFolder, _
            "-outfile", "1.exe", "-BappVersion=" & txtVersion.Text, "-appclass", appClass, _
            "-Bidentifier=" & appClass))


systemWide=boolean
Flag that indicates if the application is installed in Program Files or in the standard location in the users home directory. Set to true to install the application in Program Files. Set to false to install the application in the user's home directory. The default is false.
 

LWGShane

Well-Known Member
Licensed User
Longtime User
This is one little amazing utility!

Thanks!
 

tdocs2

Well-Known Member
Licensed User
Longtime User
Greetings.

I need your help. I am convinced that this file came from Inno Setup.

I do not know if it is real malware as it was detected by Norton Sonar....

Any feedback is appreciated.

Thank you.

Sandy
 

Attachments

  • InnoNorton.png
    InnoNorton.png
    15.8 KB · Views: 421

eurojam

Well-Known Member
Licensed User
Longtime User
Try this for the menu name. Add the following line after the args.AddAll line:
B4X:
args.AddAll(Array("-BmenuHint=true", "-Bwin.menuGroup=Test"))

Attached is a version where I added the above line - also in the form - and the possibility to add a Desktop shortcut (windows only).
B4X:
args.Add("-BshortcutHint=true")
 

Attachments

  • B4JPackager.zip
    4.9 KB · Views: 466
Status
Not open for further replies.
Top