6

I'd like to use Gradle, but from the User Guide:

For running Gradle, add GRADLE_HOME/bin to your PATH environment variable. Usually, this is sufficient to run Gradle.

What is the "best" place to add this? I'm the only user of elementary OS.

10

A path set in .bashrc will only be set in a bash interactive non-login shell, it won't be set in applications launched directly from the GUI nor (if you log in remotely) when you log in over SSH. If you put your path in .profile or /etc/profile.d it will be available to your complete desktop session.

Please, change /path/to/your/gradle in my examples with your actual gradle path.
Both solutions will take effect after your next login.

Systemwide setting

There are many ways to set a systemwide variable, but in my opinion the most clean & elegant approach is a separate script in /etc/profile.d.

First, create a new file, make it executable and open it with an editor:

sudo /etc/profile.d/gradle.sh
sudo chmod +x /etc/profile.d/gradle.sh
sudo -i scratch-text-editor /etc/profile.d/gradle.sh

then add the following lines into it:

export GRADLE_HOME=/path/to/your/gradle
export PATH="$PATH:$GRADLE_HOME/bin"

User specific setting

open your local .profile file:

scratch-text-editor ~/.profile

and add the following lines at the end of this script:

export GRADLE_HOME=/path/to/your/gradle
export PATH="$PATH:$GRADLE_HOME/bin"
| improve this answer | |
  • now i know how to add programs in Ubuntu ^_^ – moldovean Apr 15 '16 at 8:32
0

You can put it in /etc/environment (it will work for every user) or in your .bashrc file (variable would be valid only through bash) located in your home directory.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.