The Mathematica Path


This section describes how the path is set when Mathematica is launched. It may be useful to have an understanding of the different types of Mathematica projects, as described in the projects section.

Default Behavior

The default behavior is that the root of the project is put on the Mathematica path. This means that a file at the top of the project can be loaded with a relative instruction. For example, in the following project, the file Test.m is at the root of the project.

Path

This file can be loaded with a Mathematica command such as <<Test.m. If you are running through the notebook front end, this could be entered into an input cell and evaluated.

If the file is located in a folder, the loading command should include the name of the folder. For example, to load a file from the folder named Code, you would execute the command <<Code/Test.m.

Modifying the Path

In certain cases, you may want to change the path because your Mathematica source code is located more deeply in the project. This can be done by modifying the Mathematica path resources.

Mathematica Applications

It should be noted that the default location for the path also works well for Mathematica applications. For example, in the following application project, the application can be loaded with a Mathematica command such as <<TestApp`.

Path

Note that the project can be set up to execute a command such as this in an initialization command. This is described in the initialization section.