Guides/Auto Start
We will look at ways to automatically launch J scripts from file browser and web browser.
It is required that
- J is installed locally on the system
- Script is launchable, i.e. it executes a GUI program as its last line
- Script is self-contained or loads other scripts from existing J installation
Examples
Here are some examples of existing launchable scripts
- Typesetting/Font Fit attachments, right from the page on Windows
- Typesetting/Font Size attachments, also
- many files in J system\examples\demo folder
- system\examples\graphics\isigraph\isdemo.ijs
- system\examples\graphics\opengl\simple\gldemos.ijs
- addons\sqlite\browser.ijs
Windows
Windows XP platform is the most straightforward. We only need to register a new file type right from the Explorer as shown below. (For a Windows Vista solution see Guides/Auto Open).
As a result, J scripts both from local disk and from the Internet are automatically launched on (double) click.
Mac OS X
Mac requires a hack. As Finder clicked documents are not passed as command line arguments, but as Apple Event. So we need an AppleScript to get the argument.
Also it's not possible so far to launch from a web browser directly. But saving to Desktop and launching works. Share if you know how to improve this.
- Download J_Launcher.zip and double-click
- Place J Launcher application in ~/j601 or anywhere else.
- You may need to relaunch Finder: Alt+Right-Click Finder icon in Dock, select Relaunch.
Now all .ijs files are associated with J and will start J if launchable. First time answer the dialog to open the J Launcher application.
Gotchas
- It makes sense to have a separate extension from .ijs for launchable scripts, e.g. .ija for "auto start".
- A more elaborate protocol similar to Java Web Start is possible to download, maintain and launch composite script applications.
Related Technologies
- Java Web Start, Java Network Launching Protocol, JNLP
- JAL, J Application Library
See Also
Contributed by Oleg Kobchenko