A Mathematica application is a collection of resources that enhance Mathematica. This can include packages, data files, documentation, palettes, stylesheets, database definitions, and J/Link classes. Including these into a application makes it easy to install and use them from within Mathematica. Many Mathematica tools such as J/Link and DatabaseLink are built as Mathematica applications.
The contents of a sample application are shown below.
MyTool MyTool.m Utilities.m PacletInfo.m Kernel init.m FrontEnd Palettes palette.nb Stylesheets styles.nb Documentation English
Mathematica packages can be placed into the application. In the example above, there are two packages, Package.m and Utilities.m. Typically, there will be one main package and other subsidary packages. The main package is loaded via the init.m, as explained below.
In this example, MyTool.m, which is the main package, starts with BeginPackage["MyTool`"] and Utilities.m starts with BeginPackage["MyTool`Utilities`"].
A Mathematica application can be installed in a number of places. The most useful are two locations that Mathematica searches for applications: $BaseDirectory/Applications and $UserBaseDirectory/Applications. The first location is common to all installations of Mathematica and the second is unique to the current user logged into the computer.
You can find the value of $BaseDirectory by executing it in Mathematica.
In[1]:= $BaseDirectory Out[1]= "C:\Documents and Settings\All Users\Application Data\Mathematica"
If it is installed correctly then packages from the application can be loaded into Mathematica with Get or Needs. To load the main package, MyTool.m, you can use the following command.
In[2]:= << MyTool`
This works by loading the Kernel/init.m. The name to find the main package inside the application is MyTool`MyTool`. The name MyTool` actually finds the init.m file.
In[3]:= FindFile[ "MyTool`"] Out[3]= "C:\Documents and Settings\User\My Documents\work\Eclipse_workspaces\MyTool\MyTool\Kernel\init.m"
The Kernel/init.m is set to load the main package.
In[4]:= FilePrint[ FindFile[ "MyTool`"]] (* Mathematica Init File *) Get[ "MyTool`MyTool`"]
Typically, if you create the application via the Workbench, setting up these files is done for you. You can place other commands into the Kernel/init.m, but you need to be quite careful not to do too much, and often it is best just to stick with loading the main package.
You can create documentation for your application and have it show up in the Mathematica help system. This is described in the section on documenting your application.
A key element of the way that Mathematica works with documentation in your application is the PacletInfo.m. This is a descriptor file that describes the contents of the application. An application needs a PacletInfo.m if it wants to provide documentation. If it does not provide documentation the PacletInfo.m can be omitted.
The Workbench provides a special multi-page editor for working with the PacletInfo.m. This provides convenient tools for changing details of the editor and working with the features it supports.