...
- 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` - Set the environment variable PATH.
set 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.
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
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
DrJava-HJ - Download and Install
DrJava-HJ is the gui for HJ. You can edit, compile and run HJ programs from within this gui.
- 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 Lets call the jar file . Lets call it 'drjava’drjava-hj-version.jar'jar’.You are all set to use the
DrJava-HJ
...
- Setup
There is no setup needed for DrJava-HJ.
Testing
Do Here are the following to check if instructions to compile and run HJ programs using the DrJava-HJ gui is setup properly.
- 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-version/examples/HelloWorld’, which contains an HJ program, HelloWorld.hj
Select FibHelloWorld.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 10You should get the following output.
55HelloWorld - DO NOT use the gui with different options for ’-places’.
- DO NOT use the gui for timing your executions.