Download and Setup
...
Instructions for Habanero-Java (HJ)
...
installations
There are two installations available for HJ. One uses an IDE installation called DrHJ which works on Linux, Mac OS, and Windows. The other uses a command-line installation, which is only supported Note that the HJ package is meant to run only on Linux and MacOS but not Windows. 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.to a Linux lab machine to use the command-line installation. Please contact Vincent Cavé if you have any questions with installing any of the software listed below. You can find a number of sample HJ programs and lab exercises in the COMP 322 web page.
1) DrHJ - Download and Install
DrHJ is an IDE for HJ. You can edit, compile and run HJ programs from within this IDE. DrHJ runs on Unix-based platforms (e.g., Ubuntu, Mac OS, etc) and also on some Windows installations. (For Windows, you should download a standard full JDK from Oracle to maximize the chances of DrHj working on your system.)
- Download the jar file corresponding to DrHJ
- This jar file should be called ’drhj.jar’. If not, please use the actual name instead of drhj.jar in the instructions below.
DrHJ - Setup
There is no setup needed for DrHJ.
DrHJ - Testing
Here are the instructions to compile and run HJ programs using the DrHJ IDE.
- Open the DrHJ IDE
java -jar drhj.jar - Now you should have the DrHJ IDE running.
- Open a HJ program.
Click on the open button on the top panel
Navigate to the folder ’hj-version/examples/HelloWorld’, which contains an HJ program, HelloWorld.hj
Select HelloWorld.hj and click open - Compile the HJ program.
Click on the compile button on the top panel - The 'Compiler Output' tab in the bottom panel should show 'Compilation Completed'.
- 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.
- Go to the 'Interactions' tab in the bottom panel. Run the program by typing the following.
run HelloWorld
2) HJ - Download and Install
You will have to download and install HJ once for every machine you plan to use HJ on.
- 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
- Lets call the zip file ’hj-version.zip’.
- Unzip the file
unzip hj-version.zip - 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.
...
- Set the environment variable HJ HOME to the ’hj-version’ folder.
export HJ_HOME=<full-path-to-hj-version-folder>
OR
Testing
Do the following to check if your HJ is setup properly.
- 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 - Compile the HJ program, Fib.hj
hjc Fib.hj - Run the HJ program with appropriate arguments, Fib with an input 10.
hj Fib 10 - You should get the following result, which is the Fibonacci value of 10.
55
DrJava-HJ
- 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
- Now you have the jar file. Lets call it 'drjava-version.jar'.
- 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.
- <Go to the hj-version folder>
export HJ_HOME=`pwd`
Note that you need to use `backquote` in the above command. - Set the environment variable PATH.
export PATH=$HJ_HOME/bin:$PATH - 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
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.
- Set the environment variable HJ HOME to the ’hj-version’ folder.
setenv HJ_HOME <full-path-to-hj-version-folder>
OR
<Go to the hj-version folder>
setenv HJ_HOME `pwd`
Note that you need to use `backquote` in the above command. - Set the environment variable PATH.
setenv PATH ${HJ_HOME}/bin:${PATH} - 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.
setenv JAVA_HOME <full-path-to-java-sdk>
In your lab machines, the java sdk can be found at /etc/alternatives/java
HJ - Testing
Now you are all set to compile and run HJ programs. Here are the instructions to compile and run an HJ program in the command line.
- Go to the folder ’hj-version/examples/HelloWorld’ which contains an HJ program, HelloWorld.hj.
- Compile the HJ program
hjc HelloWorld.hj - Run the HJ program
hj HelloWorld - This should print ’HelloWorld’.
- To control the number of places and threads your HJ program runs on, use the ’-places’ option as follows.
hj -places 1:2 HelloWorld // This runs on 1 place with 2 threads - Open the DrJava-HJ gui
java -jar drjava-version.jar - Now you should have the DrJava-HJ gui running.
- 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 - Compile the HJ program.
Click on the compile button on the top panel - The 'Compiler Output' tab in the bottom panel should show 'Compilation Completed'.
- 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.
- Go to the 'Interactions' tab in the bottom panel. Run the program by typing the following.
run Fib 10 - You should get the following output.
55