# OS X Installation

> - Installation
> - Memory
> - Upgrading
> - Drag and Drop
> - Known Problems
> - Adding JAR Files
> - Switching Java Versions
> - Running from the Command Line
> - About the Icon

> ### Installation

> To install ImageJ, download the Mac OS X .tar.gz file and double-click on it to extract the "ImageJ (OS X)" folder. To run ImageJ, open this folder and double-click on the ImageJ icon.

> ### Memory

> With ImageJ 1.32 or later, use the Edit/Options/Memory command to make more than 192MB of memory available to ImageJ. Setting the "Maximum Memory" value to more than about 75% of real RAM may result in poor perfomance due to virtual memory "thrashing". The maximum amount of memory that can be allocated is about 1.8 GB. Another way to make more memory available to ImageJ is by running from the command line and using the -Xmx option. Note that ImageJ is limited to 64MB when you run it by double clicking on ij.jar.

> ### Upgrading

> To upgrade to the latest version of ImageJ, replace the ij.jar file in the ImageJ folder with a newer one from http://rsb.info.nih.gov/ij/upgrade/. With ImageJ 1.34 and earlier, control-click on the ImageJ application, select "Show Package Contents", then drag the newer ij.jar into the Contents/Resources/Java folder. You can also update ImageJ using an Applescript application written by Gilles Carpentier.

> ### Drag and Drop

> The OS X version of ImageJ opens images, text files, ROIs and LUTs that are dropped on the ImageJ icon.

> ### Known Problems

> 1. ImageJ sometimes crashes on OS X. Upgrading to the latest version of Java should reduce the number of crashes. This bug has been reported to Apple (ID# 3488737).
> 2. ImageJ cannot use more than about 1.8GB of RAM. This has been submitted to Apple as bug #3492928.
> 3. OS X requires a lot of memory for each open window. Converting a 1024x1024x10x8-bit stack (10MB) to separate images requires 58MB of additional memory!
> 4. There does not appear to be a way to unselect an ROI in the ROI Manager (java.awt.List bug). As a workaround, press the "Unselect" button.
> 5. Image drawing is very slow. The Plasma plugin and Plasma2 applet are test cases for this problem.
> 6. The available memory value displayed by ImageJ (1.32h or later) is 64MB too high when ImageJ is started by double-clicking on ij.jar or run from the command line due to a bug in Java's Runtime.maxMemory() method.
> 7. With Java 1.4.2, the cursor is always an arrowhead. This bug has been reported to Apple (ID# 3761991). A test case applet is available.

> ### Adding JAR Files

> Some plugins require adding a JAR file to ImageJ. In ImageJ 1.31 or later, this is done by copying the JAR file into the plugins folder or an immediate subfolder of the plugins folder, then restarting ImageJ. To compile a plugin that uses a JAR file, copy the JAR file to /Library/Java/Extensions.

> ### Switching Between Java 1.4.2 and Java 1.3.1

> The ImageJ double-clickable application uses Java 1.4.1 or later. To use Java 1.3.1, control-click on the ImageJ application, select "Show Package Contents", open the "Contents" folder, drag and drop "Info.plist" on TextEdit, then change the value of the Root>Java>JVMVersion property from "1.4+" to "1.3.1". Duplicate ImageJ before making these changes to create separate Java 1.3.1 and Java 1.4 versions.

> Note: Panther (OS X 1.3) users should avoid Java 1.3.1 since the combination of Panther and Java 1.3.1 seems to cause frequent ImageJ crashes.

> It is possible to revert to Java 1.3.1 when running Java programs from the command line or by double clicking on a jar file by typing these two commands into a Terminal window:

> > cd /System/Library/Frameworks/JavaVM.framework/Versions
> > sudo ln -sfh 1.3.1 CurrentJDK

> This switches the symbolic link for the current JDK to 1.3.1. You can view what the CurrenJDK is pointing to by running (in the same directory):

> > ls -al

> ### Switching Between Java 1.4.2 and Java 5.0

> On OS X 10.4, the Java Preferences utility in /Applications/Utilities/Java/J2SE 5.0/ allows you to switch between Java 1.4.2 and Java 5.0:
> 1. Launch Java Preferences
> 2. Click on the General tab
> 3. In the Applications area, drag J2SE 5.0 or J2SE 1.4.2 to the first position
> 4. Click the Save button

> ### Running from the Command Line

> To run ImageJ from the command line, open a Terminal window, cd to the ImageJ directory, then use the java command to run ImageJ. The easiest way to do this is to drag the ImageJ folder to the Terminal Window, type return, then type:

> >     java -jar -mx256m ij.jar
> >     (or java -mx256m -cp ij.jar ij.ImageJ)

> The -Xmx256m switch specifies that ImageJ will have available a maximum of 256MB of RAM.

> Here is a simple AppleScript that sends commands to Terminal to have it automatically launch ImageJ:

> >     tell application "Terminal"
> >         run
> >         do script with command "cd /Applications/ImageJ
> >             java -jar -mx350m ij.jar"
> >     end tell

> Or use AppleScript's "do shell" command:

> >     do shell script "cd /Applications/ImageJ;java -jar -mx350m ij.jar"

> These Applescripts assume that ImageJ 1.35 or later is in the Applications folder. For more information, Gilles Carpentier has a web page that explains how to send commands to ImageJ from AppleScript.

> With OS X 10.1 or later, you can also run ImageJ by double-clicking on ij.jar.

> ### About the Icon

> The ImageJ icon for OS X is based on a photograph by Tom Grill of a
> Hartnack microscope, circa 1870's, at www.arsmachina.com. A full size PNG version of the icon is available at rsb.info.nih.gov/ij/images/ImageJ.png. An article
> on O'Reilly's macdevcenter.com site explains how to create photorealistic
> icons for Mac OS X.