Setting Up Local Machine

Downloading coatjava:

  • Create a jlab_software directory which we will store the coatjava package in and move into that directory.
    • mkdir jlab_software
    • cd jlab_software
  • Then download the 2.0 version of the coatjava package from JLab's website and untar it:
      • wget https://userweb.jlab.org/~gavalian/software/coatjava/coatjava-2.0.tar.gz
    • tar -xf coatjava-2.0.tar.gz
  • Once it has been successfully untarred, you can remove the downloaded file.
    • rm coatjava-2.0.tar.gz

Now you not only have the coatjava package to run the reconstruction software, but you also have the SNAPSHOT package within the coatjava package to develop code for JLab! However, we will need to make sure that we set some things up first...

Installing the JDK:

  • Simply download and install the Java Development Kit (JDK):
    • sudo yum -y install java-1.8.0-openjdk-devel
  • You can test to make sure it installed properly by running the command:
    • javac -version

On my machine, this displays that I have javac version 1.8.0_51.

Installing Groovy:

  • First, download the Groovy software development kit (sdk) bundle:
    • wget dl.bintray.com/groovy/maven/groovy-sdk-2.4.3.zip
  • Unzip groovy-sdk-2.4.3.zip into the /usr/bin directory:
    • sudo unzip -q groovy-sdk-2.4.3.zip -d /usr/bin/
  • Remove the zip folder:
    • rm groovy-sdk-2.4.3.zip
  • Next, we need to alter some environment variables. Enter in:
    • sudo nano /etc/profile.d/environment.sh
  • and add these lines to the newly created shell script file:
    • GROOVY_HOME=/usr/bin/groovy-2.4.3
    • PATH=$PATH:$GROOVY_HOME/bin
  • Finally, activate the new path settings
    • source /etc/profile.d/environment.sh
  • and check to see if you have successfully installed Groovy by entering in:
    • groovy -v

This should return the version of Groovy that you have just installed, along with some other information.

Installing Maven:

  • First, make a directory to house the apache-maven binary distribution:
    • sudo mkdir /usr/local/apache-maven/
  • Download the binary distribution:
    • wget http://mirror.sdunix.com/apache//maven/maven-3/3.3.3/binaries/apache-maven-3.3.3-bin.tar.gz
  • Extract the distribution archive in the directory you made for it:
    • sudo tar -xf apache-maven-3.3.3-bin.tar.gz -C /usr/local/apache-maven/
  • Remove the tar file:
    • rm apache-maven-3.3.3-bin.tar.gz
  • Edit environment.sh:
    • sudo nano /etc/profile.d/environment.sh
  • and update the file such that MAVEN_HOME is set to the unpacked distribution's folder and add its bin to the PATH environment variable:
    • MAVEN_HOME=/usr/local/apache-maven/apache-maven-3.3.3
    • PATH=$PATH:$GROOVY_HOME/bin:$MAVEN_HOME/bin
  • You may also want to add the MAVEN_OPTS environment variable to specify JVM properties (it is used to supply extra options to Maven). If so, add the following line to environment.sh:
    • export MAVEN_OPTS=”-Xms256m -Xmx512m”
  • Activate the changes you made:
    • source /etc/profile.d/environment.sh
  • Check to see whether the installation was successful by entering in:
    • mvn -version

This should return the version of Maven that you have just installed along with some other information.

Installing Eclipse:

  • Download Eclipse:
  • Untar the downloaded file into the /usr/local/ directory:
    • sudo tar -xf eclipse-java-luna-SR2-linux-gtk-x86_64.tar.gz -C /usr/local/
  • Remove the tar file:
    • rm eclipse-java-luna-SR2-linux-gtk-x86_64.tar.gz
  • Edit environment.sh:
    • sudo nano /etc/profile.d/environment.sh
  • and add the following line to create a shortcut to activate eclipse from the terminal:
    • alias eclipse="/usr/local/eclipse/eclipse &"
  • Finally, activate the changes you made:
    • source /etc/profile.d/environment.sh
  • You now should be able to launch eclipse from the terminal by entering in "eclipse".

Setting up Eclipse:

  • First, choose your workspace folder to be "$HOME/workspace", and make sure that the "Use this as the default and do not ask again" box is checked before continuing.
  • Next create a new Maven Project: File -> New -> Project -> Maven -> Maven Project, then click "Next >"
  • Make sure that the "Create a simple project (skip archetype selection)" box is checked and click "Next >"
  • Fill in the following information in the Artifact section:
    • Group Id: org.jlab.clas
    • Artifact Id: clasrec-ec
    • Version: 2.0-SNAPSHOT
    • Packaging: jar
  • Name your project and give it a description if you want. Afterwords, click "Finish".
  • Eclipse automatically creates a pom.xml file for the Maven project, however, you will want to replace it with the pom.xml file that can be found at the bottom of this page.
  • Right click on your project and click on Maven -> Update Project.
  • Next, go to Help -> Eclipse Marketplace, find Groovy/Grails Tool Suite (GGTS) and install it.
  • Restart Eclipse, then right-click on your project and go to Configure -> Convert to Groovy Project.
  • Finally, create two new source folders to store your Groovy classes and scripts:
    • src/main/groovy
    • src/test/groovy

Now you should be all ready to go!

*Note*: In order to run a Groovy script, go to the script you want to run and click on Run -> Run As -> Groovy Script.

Now that you have finished all the steps, download, TestScript.groovy, place it in the src/test/groovy folder and try to run it. If you see a canvas with a histogram drawn on it then you should be good to go!

Groovy Command Line:

  • If you would like to use Groovy with the command line, go to the directory $HOME/.groovy and make a lib directory.
    • cd $HOME/.groovy
    • mkdir lib
  • Finally copy the coat-libs-2.0-SNAPSHOT.jar into the directory you just created.
    • cp jlab_software/coatjava/lib/clas/coat-libs-2.0-SNAPSHOT.jar .groovy/lib/

Now you should be able to run groovy scripts with JLab code in the command line by typing:

  • groovy nameOfGroovyScript.groovy