Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm trying to run IntelliJ from Gnome3's Applications menu, but it complains the JAVA_HOME variable is not set.

I have the Java installation under my home folder.

I managed to export the variable in my ~/.bashrc:

export JAVA_HOME=~/jdk1.6.0_32

and I successfully ran IntelliJ from the command line.

I thought it's normal that configuration is ignored as Gnome should not assume we are using bash, isn't it?

I hoped that .profile to be the correct place to use, but it does not seem to have any effect.

share|improve this question
Can you clarify what you mean by "ignored"? If the environment variable is indeed set but its value is not being used, then you have a Java configuration problem, and not an environment issue. I have never needed to set $JAVA_HOME but I always use the distribution's pre-packaged java install. – jw013 May 14 '12 at 15:13
@jw013 I mean that it does not appear when I run env within bash, and naturally IntelliJ doesn't keeps complaining when run from the Gnome3 menu entry. – logic.town May 14 '12 at 15:18
Did you restart gnome since you added that? – Mat May 14 '12 at 17:03
Have you a ~/.bash_profile and/or ~/.bash_login? They are preferred over ~/.profile, if they exist – enzotib May 14 '12 at 20:27
If you put the definition in .bashrc, it will only be available in applications launched from a terminal. If you put it in ~/.profile, the definition is read when you log in on most, but not all systems. This can depend on your distribution, on your login manager, on your session manager and on your desktop environment. What login manager do you use (e.g. gdm, kdm, …)? What session type do you select? What window manager are you running? What version of Debian? Also, do you have a ~/.bash_profile or ~/.bash_login, and does it work if you put the definition there? – Gilles May 14 '12 at 23:06

According to Ubuntu's Wiki on Environment Variables either in ~/.pam_environment or in /etc/environment, depending on what you want it for all users, or just your user.

Session-wide environment variables

Environment variable settings that should affect just a particular user (rather then the system as a whole) should be set into:

~/.pam_environment - This file is specifically meant for setting a user's environment. It is not a script file, but rather consists of assignment expressions, one per line.

Note: Using .pam_environment requires a re-login in order to initialize the variables. Restarting just the terminal is not sufficient to be able to use the variables.


System-wide environment variables

Environment variable settings that affect the system as a whole (rather then just a particular user) should not be placed in any of the many system-level scripts that get executed when the system or the desktop session are loaded, but into

/etc/environment - This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line. Specifically, this file stores the system-wide locale and path settings.

share|improve this answer
Sorry, but I think this is not the recommended way for a Debian system, is it? BTW, any idea why .profile seems to be ignored by Gnome/X11? – logic.town Jun 18 '12 at 11:07
Ubuntu is mostly based on Debian, there should be no problem using this method. And .profile is only used by Bourne style shells. It has nothing to do with X. – bahamat Jun 18 '12 at 20:07

For Environment variables to be visible inside X11 applications you start from GNOME menus, you may want to export this variable in /etc/X11/xinit/xinitrc. This file is sourced when an Xsession is started.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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