Contents
Separating User data from J program installation for J6.01
Introduction
Note that the contents of this page refer to J6.01. Significant improvements were made to the J6.02 install routines that now make customising installs much easier - see System/Installation.
Objectives and reasons
- To separate the code that users create from the physical installation of J itself.
- To store the code that users create in their normal data store.
- To provide the ability for multiple users on the same computer to share a single installed copy of J, while maintaining their own configurations and data.
Why?
- This model is common behaviour for programs on the Windows platform and enabling J to conform to this behaviour will increase its acceptance by new users on this platform.
- This model makes it easier for users to create backup solutions.
Caveats
The ideas below are from my own limited experience (and expertise) and my reading of the forum and J help. I haven’t tested all the all ideas discussed below, and those that I have tested were only tested on Windows XP SP2 - so use the suggestions at your own risk!
I’m not sure how “supported” any of these configurations are by JSoftware. There may well be issues that I’m not aware of that mean the following suggested configurations are “a bad idea”. In which case it may be best to delete this page!
The following comment from Eric Iverson, in a discussion about this topic, suggests that it might be a good idea to wait for J6.02 before tackling this problem.
from Eric Iverson <eiverson@sympatico.ca> Jun 21 to General forum <general@jsoftware.com> date Jun 21, 2007 9:22 AM subject Re: [Jgeneral] Profile.ijs comments There are some changes in 602 in installs and how the JFE/JE/profile/standard library interact. I hope to get a preliminary beta out by the end of next week. You might consider putting more effort in this area on hold until you have the new version to work against.
Please feel free to edit this guide or add comments/suggestions/improvements/disagreement.
Approach
The code changes to profile.ijs are the same wherever it is located. There are three suggested locations for the profile.ijs:
the default location of the profile.ijs in the J installation folder or,
a sub-folder of the J installation e.g. \j601\user\config\profile.ijs
a sub-folder of the users' data store e.g. \My Documents\Jcode\config\profile.ijs.
Pros and Cons
Each option has its advantages and disadvantages:
the default location in the J installation
- probably the simplest and easiest to implement
- resulting configuration is most similar to the default J install
- don’t have to use –jprofile switch in command line of Shortcuts (decreases flexibility for using other options)
- you will have to make sure that the file isn’t overwritten during any (re)install of J into the same folder
If you have multiple versions of J installed you will need to maintain multiple versions of your edited profile.ijs
sub-folder of the J installation
- resulting configuration is less similar to the default J install
- have to use –jprofile switch in command line of Shortcuts (decreases flexibility for using other options)
- your custom profile will not be affected by a (re)install of J in to the same folder.
- your custom profile can be used for multiple versions of J installed
sub-folder of each user's data store
- the same pros and cons as 2nd option and in addition:
- more likely to get backed up
- more likely to be moved when moving to a new computer
- resulting configuration most different from the default J install
- have to make changes in multiple places if profile needs to be edited
Implementation
Assumptions
J is installed in C:\Program Files\j601
- Users of the computer will keep their J data files in:
<path>\Documents and Settings\<username>\My Documents\Jcode
Locations
the default location in the J installation
- Make a copy of the original C:\Program Files\j601\profile.ijs so that you can restore it if need be.
Edit C:\Program Files\j601\profile.ijs as detailed below
sub-folder of the J installation
Copy C:\Program Files\j601\profile.ijs to C:\Program Files\j601\user\config\profile.ijs
Edit C:\Program Files\j601\user\config\profile.ijs as detailed below
The command line for the shortcut to put in \Documents and Settings\All Users\Start Menu\Programs\J is:
"C:\Program Files\j601\j.exe" -jprofile "C:\Program Files\j601\user\config\profile.ijs"
sub-folder of each user's data store
Make a copy of C:\Program Files\j601\profile.ijs for editing
Edit profile.ijs as detailed below
Copy the edited file to \My Documents\Jcode\config\profile.ijs for every user
The command line for the shortcut to put in \Documents and Settings\All Users\Start Menu\Programs\J is:
"C:\Program Files\j601\j.exe" -jprofile "%USERPROFILE%\My Documents\Jcode\config\profile.ijs"
Changes to profile.ijs file
This first part of profile.ijs is unchanged from the original.
NB. =========================================================
NB. various global definitions
NB.
NB. Here, verb jhostpath converts between path separators / and \
NB. as required by the host system. For example, under Windows:
NB. jhostpath 'system/main/dates.ijs'
NB. system\main\dates.ijs
3 : 0 ''
notdef=. 0: ~: 4!:0 @ <
if. notdef 'ARGV' do. ARGV_z_=: ,<'undefined' end.
if. notdef 'PROFILE' do. PROFILE_z_=: 1!:45'' end.
PATHSEP_j_=: '/\'{~6=9!:12''
jhostpath_z_=: PATHSEP_j_ & (I. @ (e.&'/\')@] })
''
)
NB. =========================================================
NB. create SYSTEMFOLDERS
NB. the entry for binary is added in boot.ijs
sep=. PATHSEP_j_
prf=. PROFILE {.~ PROFILE i: sep
add=. prf,sep,'addons'
sys=. prf,sep,'system'
hlp=. sys,sep,'extras',sep,'help'
The next 3 lines define the user, temp and config folders in the original profile.ijs and have been commented out.
NB. tmp=.prf,sep,'temp' NB. usr=.prf,sep,'user' NB. cfg=.usr,sep,'config'
Either of the next 2 lines should provide the path to the My Documents folder for the user that is currently logged in. Maybe one is safer than the other?? If you don't need to support multiple users you can hard code usrdata to point to the folder of your choice.
usrdata=. (2!:5 'USERPROFILE'),sep,'My Documents' NB. usrdata=. (2!:5 'HOMEDRIVE'),(2!:5 'HOMEPATH'),sep,'My Documents' usr=. usrdata,sep,'Jcode' tmp=. usr,sep,'temp' cfg=. usr,sep,'config'
hom=. (0&e. { ;&prf) 2!:5 'HOME'
ids=. ;: 'profile system addons temp user config help home'
SYSTEMFOLDERS_j_=: ids ,. prf;sys;add;tmp;usr;cfg;hlp;hom
NB. =========================================================
NB. boot up J:
NB. note: this may load a command line script, and should be
NB. the last entry in this script. Any additions beyond this
NB. point may confuse things and cause failures.
0!:0 <jhostpath sys,'\extras\util\boot.ijs'
Alternative Approach to Customizing "profile.ijs"
The following is how I (Devon) use my own directories for my own code and "temp" area to which the *.ijx session files are saved. This is adapted from the reference * general/2006-October/027969 below.
On investigation, I realized J has a configuration setting that allows me to set "~User" to an arbitrary directory. If I'm disciplined enough to use "~User\" (note the initial upper-case letter) to prefix all calls to my own scripts, I can keep them wherever I want. For example, to load my own statistics functions:
load '~User\code\mystats.ijs'
This allows me to keep my code in an arbitrary directory and not under the horribly named, top-level directory "\Program Files".
After accomplishing this, it occurred to me that I often refer back to old session logs (the *.ijx files that store the contents of a J session) and I'd like to back those up as well. However, the mechanism for doing this is not as apparent as for changing "User".
So, I copied "C:\Program Files\J601\profile.ijs" to my own directory "C:\amisc\JSys" and made the following change to my custom profile:
NB. Use my own temp area.... NB. tmp=. prf,sep,'temp' tmp=. 'C:',sep,'amisc',sep,'JSys',sep,'temp'
This works fine: now my temp directories default to the directory I specify: 'C:\amisc\JSys\temp' in this case. However, I have to start J with this customization to the command line:
"C:\Program Files\j601\j.exe" -jprofile c:\amisc\JSys\profile.ijs
in order to use my custom profile, but this doesn't seem too onerous.
Note that "-jprofile" avoids loading the standard profile and "c:\amisc\JSys\profile.ijs" is the name of the script to run upon starting J. I mention this because, for a long time, I interpreted the construction
-jprofile FN
to mean "substitute FN for the profile", which is subtly different.
See Also
J601 Install see section at bottom titled "Complicated Installations"
general/2006-October/027969, Devon describes his method of separating user files from the J install.
general/2006-October/027975, Chris's reply, mentioning use of custom profile for more than one installed version of J.
programming/2006-October/003532, Devon describes problems starting application script with custom profile
NYCJUG/2007-02-13 -Problem Invoking Code from Desktop, Devon describes eventual solution in more detail (as well as more problems).
