Running Open Source Physics (OSP) on Mac OS X

In the following we describe one way of setting up your files to run Java programs using OSP and Mac OSX Terminal.

  1. Download the src folder. (Unzip it by double clicking on it if it does not unzip automatically.)
  2. Place the src folder in the Documents folder of your home directory.
  3. Create the following folder structure in the src folder.

    classes → org → opensourcephysics

  4. Move src/org/opensourcephysics/resources to src/classes/org/opensourcephysics, and create a folder called "programs" in src/org/opensourcephysics.
  5. To avoid lots of typing when running your programs, create aliases by selecting and coping the following:
    set path = (~/bin $path)
    alias mycd "cd Documents/src"
    alias myjavac "javac -d classes/ org/opensourcephysics/programs/\!:1/*.java"
    alias myjava "java -cp classes/ org/opensourcephysics/programs/\!:1"
    alias sipjavac "javac -d classes/ org/opensourcephysics/sip/\!:1/*.java"
    alias sipjava "java -cp classes/ org/opensourcephysics/sip/\!:1"
  6. Open up Terminal and type vi .cshrc and press return. Don't forget the dot in .cshrc. Then type i. Then paste what you copied. Then press the esc key. Then type :wq and press return. Don't forget the colon before wq. Close Terminal.
  7. To compile the java files in a folder called "example" in the programs folder, first open Terminal, type mycd, press return, and then type myjavac example, and press return. To then run a class called ExampleApp, you type myjava example/ExampleApp.
  8. You can write your own Java programs by placing them in the programs folder. You can use any editor that will create plain text files and allow a .java extension. For example you can use BBEdit, TextWrangler (freeware) or Word files saved as text only. BBEdit and TextWrangler have the advantage that they will color key words and comments, and they will automatically indent lines.
  9. To run any of the SIP programs from the text Introduction to Computer Simulation Methods by Gould, Tobochnik, and Christian, first download the sip folder. (Unzip it by double clicking on it, if it does not unzip automatically.) Inside the downloaded folder find the sip folder and move it to your src/org/opensourcephysics folder.
  10. In Terminal to compile any of the programs in a folder in sip, use sipjavac instead of myjavac. To run any program, use sipjava instead of myjava.
Updated 30 August 2006.