System/Starting J

From J Wiki
Jump to navigation Jump to search

Command line parameters

The J Front End puts the command line parameters in ARGV_z_. Some parameters affect JFE actions and others affect profile actions. With -jprofile and -js parameters you can start J in various ways.

In the following J is a JFE, F is the name of a script, A is 0 or more additional parameters:

J               - load profile
J F A           - load profile; profile loads F

J -jprofile     - no profile
J -jprofile F A - load F (special profile)

J -js A         - load profile
                  profile sets ARGVVERB_z_ from A and runs it

Parameters that apply only to jconsole; these will not appear in ARGV_z_:

-lib JE - path to alternate JE
-prompt - force prompt (avoid isatty test)

Examples with -js:

jconsole -js a=.23 b=.3 "echo a*b"
jconsole -js a=.23 b=.3 "echo a*b" "exit''"

Initialization sentence

JFE runs a first sentence that defines BINPATH_z_ and ARGV_z and performs other required initialization (such as loading the J profile).

BINPATH_z_ is set as the full path to the J bin folder.

ARGV_z_ is set as list of boxed string parameters from the command line.

The load of a script is done with an unnamed verb (3 : '0!:0 y') so that =. is local to the verb.

The sentence always ends with:
[ARGV_z_=:...[BINPATH_z_=:...

[A[B indicates this standard ending in the following examples.

Without -jprofile the first sentence has the form:
(3 : '0!:0 y')<BINPATH,'\profile.ijs'[A[B

With -jprofile F:
(3 : '0!:0 y')2{ARGV[A[B

Jconsole with just -jprofile:
i.0 0[A[B

Profile sequence

JFE loads the profile which in turn loads several other files to initialize your J session. The foreign 4!:3 returns script names in the order they were loaded. This can be a powerful tool in understanding the initialization process.

Start Jconsole and see what scripts are loaded.

   >4!:3''
C:\Users\Eric\j901\bin\profile.ijs
C:\Users\Eric\j901\system\util\boot.ijs
C:\Users\Eric\j901\system\main\stdlib.ijs
...

Profile errors

JFE loads profile.ijs which in turn loads several other scripts. A profile error can be difficult to debug.

In jconsole you see the error but have no information on which script has the error.

In a gui JFE there probably isn't even an ijx window to show the error.

Debugging profile errors can be difficult, but the following steps may help.

1. Start jconsole with -jprofile. This will give a bare bones ijx window in which to track down the error.

2. BINPATH_z_ is the full path to the profile.ijs to load. First make sure that it exists.

   BINPATH
C:\j901\bin
   #1!:1<BINPATH,'\profile.ijs'
1863

3. Define DisplayLoad_j_ as 1 before loading profile so that scripts are reported as as they are loaded.

   DISPLAYLOAD_j_=: 1
   0!:0<BINPATH,'\profile.ijs'
...

4. Use a text editor to examine the script with the error and fix it.

J Front End Names

The J Front End will define some names in the z locale before loading the profile:

name jconsole jqt description
ARGV yes yes command line parameters including executable path (see above)
BINPATH yes yes path of directory containing executable
FHS yes yes 0 (or 1 if j installed in the system directory of a linux or unix machine) - may change in future?
IFQT no yes 1 if jqt - may change in future
IFRASPI yes no 0 (or 1 if j was compiled to run on raspberry pi) - may change in future
LIBFILE yes yes path of J shared library (the "j engine")
RUNJSCRIPT yes no 0 (or 1 if J was started with the -jscript option) - may change in future
UNAME yes yes Operating system ('Android', 'Darwin', 'FreeBSD', 'Linux', 'OpenBSD', 'Wasm' or 'Win')

See Also: J Shell Scripts