Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Installing Groovy

Tags:

groovy

Recently I downloaded Groovy-2.3.6 and try to install it on Linux system. I follow the instruction from http://groovy-lang.org/install.html. I set my GROOVY_HOME variable.

export GROOVY_HOME=/home/work/Software/groovy-2.3.6

Then I set my environment path variable to the Groovy bin folder

  export PATH=$PATH:/home/work/Software/groovy-2.3.6/bin

The JAVA_HOME variable is already created.

Now when I'm trying to run any command of Groovy, It generate following error

Exception in thread "main" java.lang.NoClassDefFoundError: org/codehaus/groo/tool/GroovyStarter
Caused by: java.lang.ClassNotFoundException: org.codehaus.groovy.tools.GroovyStarter
      at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
      at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
Could not find the main class: org.codehaus.groovy.tools.GroovyStarter.  Program will exit.

I was going through some website to solve that problem. I find that if I set wrong path to GROOVY_HOME then it can happen. I can't figure out what should be the right path for that variable. Can anyone help me with this please. Thanks

like image 320
Deb Avatar asked Aug 06 '14 12:08

Deb


People also ask

How do I install Groovy?

Download a binary distribution of Groovy and unpack it into some folder on your local file system. Set your GROOVY_HOME environment variable to the directory where you unpacked the distribution. Add GROOVY_HOME/bin to your PATH environment variable. Set your JAVA_HOME environment variable to point to your JDK.


1 Answers

The simplest way to install Groovy on Linux/Mac is with SDKMAN. Here's what I suggest:

  • undo everything you've already done
  • install SDKMAN by running curl -s "https://get.sdkman.io" | bash
  • open a new terminal and install groovy with the command sdk install groovy 2.3.6

Going forward you can use SDKMAN to switch between different versions of Groovy (and Gradle, Grails, Griffon, etc.), install new versions, remove old versions, and so on.

like image 94
Dónal Avatar answered Oct 08 '22 20:10

Dónal