Computer Science @ PENN

caml | java 1.5 api | slashdot | webmail | wikipedia | directories | portal | van pelt library | engineering library
computer graphics & game dev (SIGGRAPH) | dining philosophers (DP) | science & tech wing (STWING) | women in cs (WICS)
CETS Answers |

Creating OCaml homework/lab projects in Eclipse

You should already have OCaml, Eclipse and OcaIDE set up. If this is not the case, follow our setup instructions. The lab computers are all set except for switching to the O'Caml perspective in Eclipse. (Window » Open Perspective » Other... » O'Caml.)

  1. Download the zip for the homework or lab, and extract the files to a temporary folder.
  2. In OcaIDE within Eclipse, click File » New » OCaml Managed Project. Enter the homework/lab name (e.g. Lab01) for "project name" and click Finish.
  3. Right click on the newly created project folder and click Import... » General » File System » Next.
  4. Click Browse, select the temporary folder containing the extracted files from the zip, and click OK.
  5. Click Select All then Finish. Expand the project folder in Eclipse to see the files that were copied into your workspace as well as some OcaIDE-generated ones which are outlined in red.
  6. Delete the temporary extract folder, otherwise you might accidentally upload these files instead of the edited files in your Eclipse workspace.

Running your homework or lab in Eclipse

In order to run (and test) your homework or lab, you must configure Eclipse to create an executable.

  1. Right click on the project folder and select Properties.
  2. Click Ocaml Project.
  3. Under "Make executable for:" check off the file that you want to run. Leave "Compilation mode" as byte-code. Press Apply and OK to close the dialog.
  4. In your project, you should now see a new item (fileName.exe). If not, make sure your code compiles without error.
  5. To run the executable, right click on fileName.exe in Eclipse and select Run As » OCaml Executable. The output of the program should appear in the Console tab. If nothing appears in the Console, you may also try Run As » OCaml Toplevel. A new OCaml Toplevel tab should appear each time you run this way.