Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

failed to set up gradle: 'Could not find the main class: org.gradle.launcher.GradleMain.'

Tags:

java

gradle

I am new to gradle and I am getting started with the Installing Gradle guide.

When I follow the guide's 'Environment variables' step, I set GRADLE_HOME as /path/to/gradle and add /path/to/gradle/bin to the PATH in ~/.bashrc.

And I run gradle -v in the command line, it gives me this error:

Exception in thread "main" java.lang.NoClassDefFoundError: org/gradle/launcher/GradleMain
Caused by: java.lang.ClassNotFoundException: org.gradle.launcher.GradleMain
    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.gradle.launcher.GradleMain.  Program will exit.

it looks like the class path is missing so I set the CLASSPATH variable to '.:path/to/gradle/lib/gradle-launcher-1.2.jar' and login again. It is still not working...

Any hints

Thx in Advance :)

like image 424
Evan_HZY Avatar asked Oct 06 '22 05:10

Evan_HZY


2 Answers

Add the following to the environment file

PATH="... :$GRADLE_HOME/bin" GRADLE_HOME="/opt/gradle/gradle-1.0-milestone-3"

Reload environment variables

source /etc/environment

Add symbolic links to the usr/bin folder

$ sudo ln -sf /opt/gradle/gradle-1.0-milestone-3/bin/* /usr/bin/.

Open a new terminal. Test installation using " gradle -v "

like image 141
Divyesh Avatar answered Oct 10 '22 04:10

Divyesh


I think using Homebrew(Package Management Software for Mac OSX) is much more easy to install and manage your all software packages if you are using Mac OSX.Today I installed gradle 2.0 by using brew command.

installing brew by using brew install and then update your brew update in order to get all current changes.

After you installed brew you can install all software packages by using brew

Command for installing Gradle:

brew install gradle

set environment of your gradle so you need to open .bash_profile in your terminal with this command: vim .bash_profile

After that you need to add this to your bash_profile

export GRADLE_HOME=$(/usr/local/Cellar/gradle/) 

HomeBrew always install all software packages into /usr/local/Cellar but I recommend that check your gradle path in your terminal.

When you try gradle -v you should see this:


Gradle 2.0

Build time: 2014-07-01 07:45:34 UTC Build number: none Revision: b6ead6fa452dfdadec484059191eb641d817226c

Groovy: 2.3.3 Ant: Apache Ant(TM) version 1.9.3 compiled on December 23 2013 JVM: 1.7.0_60 (Oracle Corporation 24.60-b09) OS: Mac OS X 10.9.4 x86_64

like image 28
Zafer Celaloglu Avatar answered Oct 10 '22 02:10

Zafer Celaloglu