Eclipse, Repast with CSCS RePast/Demos-3, on CSCS or other Computers -------------------------------------------------------------------- > > NOTE: This is a draft. Please send comments about > problems, improvements, things left out, etc to rlriolo@umich.edu ! > This note describes one way to set up Eclipse projects for programs that use the architecture used in the CSCS Demos-3 programs. The goal is to make it easy to develop and run programs under Eclipse on your own computer, then upload the java files to CSCS and run the same model there, in guimode or in batchmode (eg with drone). This also describes how to set up Eclipse on CSCS so that you can run the programs under Eclipse on CSCS computers as well. The instructions here are based on the general instructions for using Eclipse and Repast written by Derek Robinson at http://cscs.umich.edu/~dtrobins/abm/eclipse.html Thus you should read those instructions, and you could even go through all those steps for the demo project he uses, since you will have to install java, repast and eclipse in any case. In this we will use the RandomMoveInGrid demo program, from /users/rlr/RePast/Demos-3/RandomMoveInGrid/ Note that has RandomMoveInGrid -- the package name src/RandomMoveInGrid/ -- location of java files classes/ -- location of class files bin/ -- location of scripts to compile and run The layout of the directories and files in the Eclipse workspace will be similar to that, the difference being that the class files will be in classes/RandomMoveInGrid/ ====================================================================== Required Downloads ------------------ This assumes java 1.5 (5.0) and higher, RepastJ 3.1 and higher. ------------------------------------------------------------------------- Preparing Repast .jar's for use in Eclipse ------------------------------------------ For your own computer, follow Derek's instructions. For setting up your Eclipse enviroment on CSCS: - To run eclipse: eclipse & - The location of the Repast jars is /appl/repast/repast3.1/RepastJ/lib -- all the jars here /appl/repast/repast3.1/RepastJ/repast.jar -- and this one ------------------------------------------------------------------------- Setting up an Eclipse Project That Points to The Repast Libraries ----------------------------------------------------------------- Bascially follow Derek's steps, with these deviations: 6-7. - In the "Create a Java Project" window, - The project name: RandomMoveInGrid - Contents: Select Create new project in workspace - Project Layout: - Select Create separate source and output folders - Then click on "Configure default..." - In the window that comes up: Folders: Source Folder name: src Output folder name: classes - Click Apply - Click OK - Now you will be back in "Create a Java project" Click Next 8. Select the "Projects" tab 9-11. Click on "Add..." In the list box that is shown, check next to Repast, click on OK. 12. Now back in the NewJavaProject/Java Settings window, go to the "Order and Export" tab. Check the box left of the Repast fodler. 13. Click finish Note: sometimes Derek refers to a "plus sign" next to icon, folder names, etc. On my system I see the triangles that point down or right, depending on whether that folder/item contents are shown or not. ------------------------------------------------------------------------- Creating a Java Package in Eclipse ---------------------------------- Follow Derek's steps (using RandomMoveInGrid as the name). Note: Using name RandomMoveInGrid gives us a complaint about the convention for package names to start with lowercase. That is ok -- its just a warning. At this point, If you look in the eclipse workspace (eg with "ll" command in linux, or by opening folders in windows) you should see: workspace/RandomMoveInGrid/classes/RandomMoveInGrid src/RandomMoveInGrid where "workspace" is the top folder you told Eclipse to use for its workspace. -------------------------------------------------------------------------- Getting Files into your Eclipse project --------------------------------------- Now you need to cp the java files into src/RandomMoveInGrid in the RandomMoveInGrid project in the Eclipse workspace. You can use scp or other means to get them onto your machine from the cscs machines and into that folder on your machine. (See below for more ways to copy files from CSCS to your computer.) Now you should be able to see the java files in Eclipse. In the TOC panel on the left, expand the RandomMoveInGrid package (ie click on the expand icon to the left of that name). Eclipse will immediately try to compile the files! (You may need to do File->Refresh) For RandomMoveInGrid it should show a number (72 maybe) "warnings". That's ok, we can live with that. Now we need to tell eclipse how to run the model: step 1 -- black arrow just to the right of Run step 3: just above the left panel (with the "java application" that you just selected) on the left is a "new launch configuration" button -- its a icon of a page with a plus sign on the upper left for me. step 6/7 - GUIModel-RandomMoveInGrid Run -- you will see the files report.00 and report.xml.00 appear in the workspace/RandomMoveInGrid/ directory. That's it! You can now edit, recompile, run on your machine. When you are ready to do batch runs, e.g., experiments, you probably will want to copy those modified java files back to where you have them on the CSCS machines. Then you can use bin/compile.sh to compile them there, and run with bin/guirun.sh or bin/batchruh.sh . ------------------------------------------------------------------------- Copying Files from CSCS to Your Computer ---------------------------------------- You can use scp or other means to get them onto your machine and into that folder. Eg, you might want use zip to get all the java files into one file, then scp (or sftp) to your machine, then use unzip to get them into the src/RandomMoveInGrid folder. Or you might put the java files onto a memory stick and then copy them that way. One other approach: On your cscs login, in your home directory, create directory called public_html/ You can then copy files from your CSCS directory with the java files to that directory. Then you can use a browser on your home computer to go to http://cscs.umich.edu/~YourLogin where YourLogin is your cscs login. You can then download them onto your home computer. ------------------------------------------------------------------------- Copy Files from Your Computer To CSCS: -------------------------------------- Again you can use scp (secure copy) or sftp (secure ftp) to copy them, or put them on a memory stick and cp them. One way or another you want to get the files back into the RandomMoveInGrid/src/RandomMoveInGrid/ directory on the CSCS machines for this project. *** *** NOTE WELL *** *** Be sure you don't copy over files that have changes you *** want to keep in them. *** Its useful to make date-stamped jar files that have your projects in them in case you make a mistake. Eg, on the CSCS machines, get into the top-level project directory: cd RandomMoveInGrid/ then enter: jar cvf RandomMoveInGrid-yymmdd-hhmm.jar src/ bin/ where yymmdd is replaced by the year, month and day, and hh and mm are the hour and minute (approximately) when you are doing the save. It will create a "jar" archive file with all the files in src/ and bin/ . You can see what is in a jar file with jar tvf filename.jar and extract them with jar xvf filename.jar It will create any directories and COPY OVER ANY FILES that are already there -- so be careful! ------------------------------------------------------------------------- Software to move/copy files across computers: UM's ITCS provides software to do this on the "Blue Disk" which they distribute, for Windows and Macs. See this page: http://www.itd.umich.edu/bluedisc/contents.php for information about the BlueDisk. ITCS documentation about transfering files: Using SSH Secure Shell to Transfer Files with sftp Windows: http://www.itd.umich.edu/itcsdocs/s4299/ CSCS also has some pages about ssh and scp: http://www.cscs.umich.edu/PmWiki/pmwiki.php/Site/LabSecurity ------------------------------------------------------------------------