You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 22 Next »

Home

Owlspace Course Site - Section 1

Owlspace Course Site - Section 2

Office Hours

Turnin Guide

[HJ Release]

Download and Setup HabaneroJava (HJ) Package

Note that the HJ package is meant to run only on Linux and MacOS. If you have a Windows machine, you will have to remotely login to one of the lab machines and work on it. Please contact the staff if you need help to do that.

HJ - Download and Install

You will have to download and install HJ once for every machine you plan to use HJ on.

  1. Download the zip file containing the HJ package from https://svn.rice.edu/r/comp322/course/downloads/hj-1.2.0-2011-01-06.zip
  2. Lets call the zip file ’hj-version.zip’.
  3. Unzip the file
    unzip hj-version.zip
  4. This will create a folder, namely 'hj-version'

HJ - Setup

You will have to setup the environment before you can compile and run HJ programs. This has to be done every time you login to a machine or start a new shell. These commands are specific to the shell you use.

You can figure out which shell you are using with the following command.
ps -p $$

Here are the commands if you are using a bash shell.

  1. Set the environment variable HJ HOME to the ’hj-version’ folder.
    export HJ HOME=<full-path-to-hj-version-folder>
    OR
    <Go to the hj-version folder>
    export HJ HOME=`pwd`
  2. Set the environment variable PATH.
    export PATH=$HJ HOME/bin:$PATH
  3. You should have the environment variable JAVA HOME set to run HJ programs. Some machines would have it set when you log in. If it is not set already, you have to set it as follows.
    Check if your JAVA HOME is set.
    echo $JAVA HOME
    If this prints an empty line, it is not set. Do the following.
    export JAVA HOME=<full-path-to-java-sdk>
    In your lab machines, the java sdk can be found at /etc/alternatives/java sdk sun.

Here are the commands if you are using a c shell (csh) or a variant (tcsh) of it. Your lab machines’ default shell when you login is tcsh.

  1. Set the environment variable HJ HOME to the ’hj-version’ folder.
    set HJ HOME=<full-path-to-hj-version-folder>
    OR
    <Go to the hj-version folder>
    set HJ HOME=`pwd`
  2. Set the environment variable PATH.
    _set PATH=$
    Unknown macro: {HJ HOME}
    /bin:$
    Unknown macro: {PATH}
    _
  3. You should have the environment variable JAVA HOME set to run HJ programs. Some machines would have it set when you log in. If it is not set already, you have to set it as follows.
    Check if your JAVA HOME is set.
    echo $JAVA HOME
    If this prints an empty line, it is not set. Do the following.
    set JAVA HOME=<full-path-to-java-sdk>
    In your lab machines, the java sdk can be found at /etc/alternatives/java sdk sun.
HJ - Testing

Do the following to check if your HJ is setup properly.

  1. Go to a folder with an HJ program. Lets say we go to hj-version/examples/fib/ which contains an HJ program that computes the Fibonacci of a given input number.
    cd $HJ_HOME/examples/fib
  2. Compile the HJ program, Fib.hj
    hjc Fib.hj
  3. Run the HJ program with appropriate arguments, Fib with an input 10.
    hj Fib 10
  4. You should get the following result, which is the Fibonacci value of 10.
    55

DrJava-HJ

  1. Download the jar file corresponding to DrJava-HJ from https://svn.rice.edu/r/comp322/course/downloads/drjava-r5422-hj-1.2.0.0.jar
  2. Now you have the jar file. Lets call it 'drjava-version.jar'.
  3. You are all set to use the DrJava-HJ gui for HJ programs
Testing

Do the following to check if the DrJava-HJ gui is setup properly.

  1. Open the DrJava-HJ gui
    java -jar drjava-version.jar
  2. Now you should have the DrJava-HJ gui running.
  3. Open a HJ program. Lets say we open hj-version/examples/fib/Fib.hj.
    Click on the open button on the top panel
    Navigate to the folder containing Fib.hj
    Select Fib.hj and click open
  4. Compile the HJ program.
    Click on the compile button on the top panel
  5. The 'Compiler Output' tab in the bottom panel should show 'Compilation Completed'.
  6. Go to the 'Console' tab in the bottom panel and check if there were any errors during compilation. All errors will be shown in RED.
  7. Go to the 'Interactions' tab in the bottom panel. Run the program by typing the following.
    run Fib 10
  8. You should get the following output.
    55
  • No labels