Tool Setup and Usage Notes for CS453 and CS553


Creating a jar file for the MiniJava compiler

  1. Create a mainClass.txt file and put the following lines in it (NOTE: you need a blank line after the Main-Class line):
    Main-Class: Main
    
    
  2. Run the jar utility with the following command:
        % jar cmf mainClass.txt lastname-MJC.jar *.class *.java */*.class */*.java */*/*.class */*/*.java */*/*.dat
    
  3. Now you can use the jar file to run your compiler.
        % java -jar lastname-MJC.jar infile.java
    

MIPS and MARS

MARS is an editer, assembler, simulator, and debugger for MIPS assembly code. The MARS website is at http://courses.missouristate.edu/KenVollmar/MARS/. See the first three pages of their tutorial to learn how to use MARS.

See Appendix A from Patterson and Hennessy book, written by Jim Larus for more info about MIPS.


Graphviz

Graphviz is a tool for visualizing graphs, see http://www.graphviz.org/ for more information. The Graphviz executable for the Mac is awesome.

Here is how you create a graphic on the CS department machines:

  1. Create the input file: test.dot
  2. Run dot
        % dot -Tpng -otest.png test.dot
        
To generate a pdf file:
    % dot -Tps2 -Gsize=64,64 -Gmargin=0 -otest.ps2 test.dot
    % ps2pdf test.ps2 test.pdf
Here are some notes for using dot on a PC, courtesy of Eric Eastman. These notes are from 2006 so any updates would be welcome.
After getting tired of transferring my ".dot" files from my Windows XP
system where I am doing my Java work for the class, to one of the CS
department's Linux systems to display them, I finally got the Graphviz
package to run on my XP system.  Using the "dotty" viewer that comes with
the Graphviz package I can now display the graphs under XP.

I downloaded Graphviz from:

http://graphviz.org/Download_windows.php

I tried using the self-installing graphviz-2.8.exe file from this site and
had problems with it, so after de-installing it, I downloaded the
graphviz-win-2.8.bin.tgz file. This file has to be un-gzip, un-tar, and the
directories hand installed, but the dot and dotty programs work under XP. 

To display the graph of the file expr2.ast.dot that Michelle sent out last
week, I used the command:

    dotty expr2.ast.dot 

You can create a jpg file of the graph with the command:

    dot -Tjpg expr2.ast.dot  > expr2.ast.jpg


I also downloaded and installed "Tintfu", a Java based Editor/Viewer for
".dot" files which works with the Graphvis package and allows you to edit
drawings, from:

     http://tintfu.sourceforge.net/

It comes as a single "jar" file, so it's easy to install. 

Using Eclipse

see http://www.eclipse.org/ for more information
  • Build and run the program in Eclipse
    1. Start Eclipse
          % eclipse.sh
          
    2. File -> New -> Project
      1. Set Project Name to ProjName
      2. Select "Create project from existing source" and browse to find the ProjName working directory
      3. For CS453 and CS553, we often give you starter projects with a src/ subdirectory and a TestCases/ subdirectory. Take the TestCases/ subdirectory out of the build path for your project.

    3. Set up the editor to only use spaces and no tabs. This is a pet peeve of mine and of many other folks (just google "tabs versus spaces"). Your code should look the same no matter who is editing it. If you use tabs and spaces that isn't possible.
              - Window->Preferences
              - Find Java->Code Style->Formatter
              - Click on Edit...
              - Under the Indentation tab select "Spaces only" as your Tab policy
          


    Setting up a Subversion Repository and Working Directory

    1. FIRST read chapters 2 and 3 in the subversion manual at http://svnbook.red-bean.com/.

    2. Create a directory to keep all your subversion repositories for your class projects on the CS linux machines. You only need to do this step once.
          // Make sure to replace $HOMEDIR with your own unix home directory.
          // For example, /s/parsons/c/fac/mstrout
          // Replace $MACHINE with a CS unix machine that you use often.
          // Replace $USER with your username.
      
          % cd $HOMEDIR
          % mkdir SVNRepositories
          % mkdir SVNRepositories/CS553_Projects
      
    3. Create a repository for each project.
          // create the repository on a CS unix machine
          // NOTE: Each project will have its own repository.  
          // All the project repositories for CS553 will be in 
          // $HOMEDIR/SVNRepositories/CS553_Projects/.
      
          % svnadmin create $HOMEDIR/SVNRepositories/CS553_Projects/ProjName
      
    4. The remaining steps can be done on any machine. For most projects, we provide a tarball containing starting files. For example, assume that we send the file MJStart.tgz to the mailing list. You will want to unpack the tar ball and set up a subversion repository for the resulting start project.
          // upack the tarball
          % tar xzf MJStart.tgz
          
          
          // importing ProjName into the repository
          // NOTE that the ProjName and MJStart directory do NOT have to be the same.
          % cd MJStart
          % setenv SVN_SSH 'ssh -l $USER'
          // if you are using bash do the following:
          % export SVN_SSH='ssh -l $USER'
          % svn import . svn+ssh://$MACHINE.cs.colostate.edu/$HOMEDIR/SVNRepositories/CS553_Projects/ProjName -m "Initial import"
          $USER@$MACHINE.cs.colostate.edu's password: 
          Adding         ...
          ...
          Committed revision 1.
      
    5. Now get a working directory for the project. You can have as many working directories as you would like. One typical use case is to have a working directory on your laptop and another on the CS linux machines.
          // Make sure you are no longer in MJStart
          % cd ..
          
          // You can move the following into your .cshrc or other startup script.
          % setenv SVN_SSH 'ssh -l $USER'
          // if you are using bash do the following:
          % export SVN_SSH='ssh -l $USER'
          
          // for some reason the below command requires your password three times
          % svn co svn+ssh://$MACHINE.cs.colostate.edu/$HOMEDIR/SVNRepositories/CS553_Projects/ProjName/ ProjName
      
    6. Commands you will need while working:

      svn commit
      When you want to save the changes that you have made
      svn add
      To add a file or a directory
      svn update
      Pull down any changes that have been committed to the repository by your partner.
      svn info
      To check which repository and the revision number this working directory is associated with. This information is most accurate after an svn update.
      svn status
      To obtain file and directory status - added, deleted, merged, ...
      svn diff
      To compare differences between file paths
      svn log
      To display commit messages for repository
      Subversion Quick Reference Card

    7. Working with a partner
      Make sure that the permissions on the repository are set so that everyone in your unix group can write to the repository. Assume that your unix group is cs553x. Your group will have a directory at ~cs553/cs553x. Here are the commands you need to perform to set up a repository in your group directory.
      % cd ~cs553/cs553x
      % mkdir SVNRepositories
      % svnadmin create ~cs553/cs553x/SVNRepositories/Project2
      
      // check the permissions, the cs553x, SVNRepositories, and Project2
      // directories should all have group rws permissions
      % ls -al 
      % ls -al SVNRepositories/
      
      // if they don't them change the permissions
      % cd SVNRepositories
      % chgrp -R cs553x .
      % chmod g+rwxs .
      % find . -type f -print | xargs chmod g+rw
      % find . -type d -print | xargs chmod g+rwxs
      
      
    8. Using subversion with eclipse, Subversive
      On the CS linux machines, eclipse is already setup with the Subversive plugin. Instead of checking out a working directory on the command line you can do the following:
              File-->New Project-->SVN-->Project from SVN
                  Specify svn+ssh://$MACHINE.cs.colostate.edu/$HOMEDIR/SVNRepositories/CS553_Projects/ProjName/
                  
                  Use the wizard to set up a Java Project and select "Create New Project in Workspace" and provide a project name.
          
      Now you can use the subversion functionality made available via the "Team" menu item, which is visible upon a right click to a project or file.

      See http://www.ibm.com/developerworks/opensource/library/os-ecl-subversion/ for a tutorial on using subversion with eclipse.

    9. Installing Subversive on your own machine
      This is not for the faint of heart. The docs are not straight forward. Look at the instructions at http://www.eclipse.org/subversive/documentation/gettingStarted/aboutSubversive/install.php. The URL I used in the Eclipse software updates to get subversive was http://download.eclipse.org/technology/subversive/0.7/update-site/, and the URL for the subversion connectors was http://community.polarion.com/projects/subversive/download/eclipse/2.0/ganymede-site/ or http://community.polarion.com/projects/subversive/download/eclipse/2.0/galileo-site/.

    JLex and JavaCUP

    JLex is a lexer generator and JavaCUP is a parser generator.

    LaTeX

    LaTeX is a type-setting program frequently used for writing Computer Science research papers, see http://www.latex-project.org/ for more information. Download the SampleLatex project, untar it, and then do a "make" inside the SampleLatex directory. See sample.tex for an example latex file.
    Michelle Strout
    Last modified: August 21, 2009