-
Notifications
You must be signed in to change notification settings - Fork 3
Creating installers
On this page, we will show you how to create installers for your application for Linux, MacOS and Windows systems.
For the main application, you need to change the value in the starter-core module in the by.gdev.model.StarterAppConfig#DEFAULT_CONFIG class to your URI and compile this module.
In order to create an installer for older versions of the application, you need to create installers each time and add the parameter
-version old_version
Examples will be in installers
To create an installer for the Windows system, we will use the Nsis program, which can be downloaded from the link
install NSIS.
Additionally, you need to download 2 plugins Inect and Nsis7z.
Then right click on the archive->Extract all...>Select directory where installed NSIS
Download the finished archive which contains the script and the icon for link and unzip it.
It is also necessary to place the jar file starter-core-1.0.jar from the directory on the server starter-core/target/
By default it takes the http://localhost:81/starter-core-1.0.jar file from here, in your main application you should customize the .OnInit block for your application in the future.
Now the file needs to be compiled to get the installer. To do this, run the NSIS program, select item Compile NSIS Script, menu item File -> Load Script and select file createExeWindows.nsis from the archive above, which is in the directory example. After that in the directory example, .exe file will appear, whose name is determined by the command OutFile. You can run it and check if everything works correctly.
This manual was created for Ubuntu OS. To create a deb package, you need to perform a number of actions. In this example, third-party programs will not be used.
First you need to download and unzip the archive using link with a ready-made structure that you can change to suit your needs. It is also necessary to replace starter-core.jar in the release, for tests we can use the current
Description of the application hierarchy
- starter
This directory describes the package logic.
- DEBIAN
This directory contains the control manifest file with a minimum set of parameters.
Package - package name;
Version - version of the program in the package, will be used when updating the package
Section - package category, allows you to determine why it is needed
Priority - package importance, for new packages, which do not conflict with anything usually prescribe optional, also available values required, important or standard
Depends - which packages your package depends on, it cannot be installed until those packages are installed
Recommends - optional packages, but they are usually installed by default in apt
Conflicts - the package will not be installed while the packages listed here are present on the system
Architecture - system architecture on which this package can be installed, available values: i386, amd64, all, the latter means the architecture doesn't matter
Installed-Size - total program size after installation
Maintainer - specifies who compiled this package and who is responsible for its maintenance
Also, this directory can contain scripts that will be executed before/after installing/removing the package. These scripts are named preinst, postinst, prerm и postrm
preinst - executed before package installing
postinst - executed after package installation
prerm - executed before the package is removed
postrm - executed after the package is removed
- usr/games/starter
This hierarchy repeats the structure of the package, the launcher jar file is stored in the final directory.
- usr/share/applications
Contains a shortcut to launch the application. After installing the package, the shortcut will automatically appear in Show Application
Description a shortcut fields
Version - version
Name - name of the shortcut
Comment - description of the shortcut
Exec - application launch command, after jar files you can specify installer launch arguments. Full list of arguments
Icon - path to the icon, specify only the name
Terminal - the value is displayed by running the application in the terminal
Type - application type
- usr/share/icons
Contains an icon for the label name that is specified in a shortcut field Icon.
Now you need to go to the directory in which the starter directory was created and run the command
dpkg-deb --build ./starter
After executing this command, a file will appear with the same name but with the extension .deb
This file needs to be placed on the server.
Next, you need to open the terminal and run the command
nano installDebPackage.sh
And fill it with the following content
# package database update
sudo apt update
# installing a package that contains jre to run
sudo apt install -y openjdk-8-jre
# fixes broken packages in case of problems installing a package
sudo apt --fix-broken install
# script loading, after the wget command, you must specify the URI where the deb package is stored
wget https://raw.githubusercontent.com/gdevby/starter-app/master/example-compiled-app/os_installer/starter.deb
# setting execution rights
sudo chmod +x starter.deb
# start package installation
sudo dpkg -i starter.deb
# uninstalling a package after installing it
sudo rm starter.deb
Then put this script on the server.
To run and install the package, you need to run a command, this example uses a script for our application, you can adapt it for yourself.
wget https://raw.githubusercontent.com/gdevby/starter-app/master/example-compiled-app/os_installer/installDebPackage.sh -O - | sh
_* wget specifying the location of the script on your server _
To create an installer, you need to have java 8 installed, because we will use the javapackager utility
* jdk must be installed on the local machine, there is no such utility in jre
Create project directory
mkdir starter
Next, you need to place starter-core-1.0.jar from the directory starter-core/target/ in the starter directory
By default, a cup of coffee is used as an icon, to add your own icon, you need to create a file with the .icns extension and run the following commands:
# curl -O specify the path to the icon
curl -O https://raw.githubusercontent.com/gdevby/starter-app/master/example-compiled-app/icon.png
sips -z 100 100 -p 150 150 icon.png --out icon-background.png
mkdir starter.iconset
sips -z 128 128 icon.png --out starter.iconset/icon_128x128.png
iconutil --convert icns starter.iconset
Next, you need to create a package directory and use javapackager to create an installer with the following commands:
mkdir -p package/macosx
cp -v *.png *.icns package/macosx
jdk=$(/usr/libexec/java_home)
$jdk/bin/javapackager -deploy -native dmg -name starter \
-srcdir . -srcfiles starter-core-1.0.jar -appclass by.gdev.Main \
-outdir deploy -outfile starter -v
*java_home must point to the jdk directory, this path must contain the javapackager file in the bin directory
If there were no errors, then a dmg file will be created in the deploy/bandle directory
After that, you need to place this .dmg file on the server. The package is downloaded and installed using the command
curl --remote-name https://raw.githubusercontent.com/gdevby/starter-app/master/example-compiled-app/os_installer/starter-1.0.dmg && chmod +x ./starter-1.0.dmg && open -W ./starter-1.0.dmg
* This script loads our application, you can adapt it for yourself by changing the URI by which the .dmg file is available and its name