Studio/Application Distribution - Installer

From J Wiki
Jump to navigation Jump to search

Lab: Application Distribution - Installer

Wm yes check.png


This lab describes one way of packaging an application for distribution.

An app distributed this way is called an installer app (iapp).

An iapp is packaged the same way as J (exe for Windows, sh shell script for Linux, and dmg for Mac).

An iapp is complete and self-contained. It contains all of the J system (except for things like examples, labs, demos, and help) and application specific files.

An iapp installation has a folder similar to the J development environment.

Creating an iapp is done in three steps:

1. develop and test app

2. define intaller.ijs to set app contents

3. build iapp installer file from installer.ijs

We recommended you develop your app in Project Manager.

The best way to learn about iapp is to experiment with one.

The next step creates a Project Manager iapp project.

Run Project Manager and open the new apps\example project.

Open and study the 3 files.


example.ijs is the main application file.

require 'plot'

ABC=: 0 : 0
pc abc;
xywh 5 41 96 24;cc exit button;cn "Exit";
xywh 6 7 96 24;cc plot button;cn "plot 100?100";
pas 6 6;pcenter;
rem form end;

abc_run=: 3 : 0
wd ABC
wd 'pshow;'

abc_close=: 3 : 0
if. IFJIJX_j_ do. 2!:55'' else. wd'pclose' end.

abc_exit_button=: 3 : 0

abc_plot_button=: 3 : 0
plot 100?100

app.ijs loads the main app script and starts the app.

load jpath'~user\projects\apps\example\example.ijs'

installer.ijs provides information for the install program and describes the files needed by the app.

Study installer.ijs with the next few steps.

NB. see lab "Application Distribution - Installer"
NB. build installer for this application
NB.  run this installer file
NB.  build'' - builds installer

load appdist=: jpath '~system\examples\appdist\appdist.ijs'

APP_PRODUCT=: 'Plot 0.0'

NB. script that runs the application
APP_IJS=:  '~user\projects\apps\example\app.ijs'

NB. path to app.ico app.png app.icns file(s)
APP_ICON=: '~user\projects\apps\example'

NB. files (wildcards allowed) - must be in ~user
APP_COMMON=: 0 : 0

NB. 1 to lock all user ijs files

NB. ~addons\.... - addons to include
APP_ADDONS=: 0 : 0

NB. windows specific
APP_WIN=: 0 : 0

NB. linux specific
APP_LINUX=: 0 : 0

NB. mac specific
APP_MAC=: 0 : 0

First appdist.ijs is loaded to define utilities for building an iapp file.

APP_PRODUCT product - used as install folder
APP_IJS script that runs the app
APP_ICON path to icons

APP_COMMON files to include in the distribution
APP_LOCK 1 to lock all user ijs files
APP_ADDONS addons to include
APP_WIN Windows files
APP_LINUX Linux files
APP_MAC Mac files

This step loads the app installer script (which in turn loads the appdist utilities).

   load '~user\projects\apps\example\installer.ijs'

This step builds the iapp file based on installer.ijs.

copy: ~bin\profile.ijs
copy: ~system\classes\*
copy: ~system\extras\*
copy: ~system\main\*
copy: ~system\packages\*
copy: ~tools\*
copy: ~bin\j.exe
copy: ~bin\j.dll
copy: ~user\projects\apps\example\example.ijs
copy: ~user\projects\apps\example\app.ijs
installer: ~temp\app.exe

Run the installer (as you would a J install) to do the install.


Be careful with includes with * and ? wildcards as they may include more stuff than you really intended.

An installed iapp app is complete and it is not affected by any changes (new J installs, JAL updates, addons updates, development changes, etc.).


Running the app produces a desktop application.


Set APP_LOCK 1 to lock all user ijs files.

In general we encourage you to not lock files. However, if you must lock, be aware that the encryption is not strong and is secure against only casual attacks.

The iapp file creates a standard J installation with a few differences.

  bin\profilex.ijs sets ARGV and user temp config folders

  bin\icons\app.??? (ico png icns)

  ~user is in ~install

  ~config is in ~user

  ~temp is in a system temp folder


startup.ijs is not part of the iapp. Any startup.ijs dependencies in the iapp should be added to APP_IJS.

config.ijs is not normally part of an iapp. You could include it but it is probably better to have the iapp run with the default config. Provide any specific config requirements in APP_IJS. Note that ~config is in the J folder and may be a protected folder so the iapp should not depend on writes to ~config.

Information.png Debug hint: if an installed iapp fails to run, edit iapp

bin\profilex.ijs to not set ARGV and then it will start with an ijx window.

Customized profilex.ijs targetting app environment and params.

bin\profilex.ijs to not set ARGV and then it will start with an ijx window.

Customized profilex.ijs targetting app environment and params.

NB. override profile ARGV user temp config
user=. install,'\user'
config=. user,'\config'
u=. '/tmp/Plot 0.0-',":2!:5 'USER'
w=. (":2!:5'TEMP'),'\Plot 0.0'
temp=.  >(6=9!:12''){u;w
ARGV_z_=: ARGV,'-jijx';'~user\projects\apps\example\app.ijs'

End of lab

See Also