This is how I installed Groovy on Ubuntu. (Notice I run everything as sudo on my laptop)
The first step in this process is to get all the necessary files.
- If you dont have a Java JDK you will need to download one (I am using JDK 6).
- Download Groovy .zip file.
The second step is to install the files
- For java just place the JDK in the directory that you want, navigate to the directory you dumped the file and then run sh jdk-6u10-linux-i586.bin (Remember I am using Java 6 so the name of the file might be different for you.)
- For groovy, again place the downloaded file in the directory that you want. unzip the file by typing unzip groovy-binary-1.5.7.zip. (Again name of the file might change depending on the version that you downloaded.)
The third and final step in this process is to modify the PATH environment variable and add the JAVA_HOME and GROOVY_HOME to the environment variables.
- Edit the environment file by typing gedit /etc/environment
- Add and modify as necessary the following lines to the /etc/environment file.
Modify the Path variable by adding the Groovy bin directory:
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:
/usr/<locationOfGroovy>/<groovyVersion>/bin”
Add the following variables:
GROOVY_HOME=”/usr/<locationOfGroovy>/<groovyVersion>/”
JAVA_HOME=”/usr/<locationOfJava>/<jdkVersion>“
This is what my /etc/environemnt file looks like:
PATH=”/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/tools/groovy-1.5.7/bin”
LANG=”en_US.UTF-8″
GROOVY_HOME=”/usr/tools/groovy-1.5.7/”
JAVA_HOME=”/usr/tools/jdk1.6.0_10″
Once you are done, save the file, log out and log back in, change to sudo (remember I run everything as sudo) and now groovy should work. And if it doesn’t YOU messed up, because my instructions are never wrong (kidding).
You can test by typing groovyConsole in the terminal. A console should come up where you can start writting groovy code. But you should know this console is NOT and IDE, this is just a place to type and test code if needed.