英文:
Can't install Gradle
问题
无法在Ubuntu 22.04上安装或使用Gradle。
我已经下载了Gradle,解压到了/opt/gradle目录,并使用了'export PATH=$PATH:/opt/gradle/gradle-8.0.2/bin'命令,但当我在终端中运行'gradle -v'时,出现以下错误:
错误:无法找到或加载主类org.gradle.launcher.GradleMain。
我不知道如何解决这个错误。
英文:
I can't install or use Gradle on Ubuntu 22.04
I've downloaded Gradle, unzipped it into /opt/gradle and used 'export PATH=$PATH:/opt/gradle/gradle-8.0.2/bin' yet when I run 'gradle -v' in the terminal I get:
Error: Could not find or load main class org.gradle.launcher.GradleMain.
I have no idea how to fix this error.
答案1
得分: 1
尝试停止 Gradle 守护进程,通常可以解决这个问题:
gradle --stop
rm -rf ~/.gradle/caches
gradle
更好的安装方式是通过包管理器:
sudo apt install gradle
另一种选项是将 Gradle 包装器安装到您的项目中。如果您已经通过包管理器安装了可用的版本:
cd ~/my-project
gradle wrapper
./gradlew
如果您没有可用的 Gradle 版本,请从 https://github.com/gradle/gradle/releases 下载它:
unzip gradle-xxx.zip
cd gradle-xxx
cp gradlew ~/my-project
cp gradlew.bat ~/my-project
cp -r gradle ~/my-project
cd ~/my-project
./gradlew
英文:
Try stopping Gradle daemons, which usually solves this problem:
gradle --stop
rm -rf ~/.gradle/caches
gradle
A better way to install it is via the package manager:
sudo apt install gradle
Another option is to install the Gradle wrapper into your project. If you have a working version from the package manager:
cd ~/my-project
gradle wrapper
./gradlew
If you don’t have any working Gradle version, download it from https://github.com/gradle/gradle/releases
unzip gradle-xxx.zip
cd gradle-xxx
cp gradlew ~/my-project
cp gradlew.bat ~/my-project
cp -r gradle ~/my-project
cd ~/my-project
./gradlew
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论