Ubuntu – Remove annoying environment variable JAVA_TOOL_OPTIONS

14.04bashenvironment-variablesjava

Each time I run java or javac on terminal I get this annoying message

Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar

I looked up very location I know to find out where this variable in being set. I checked the following files.

  • ~/.bashrc
  • ~/.profile
  • ~/.pam_enviornment
  • /etc/bash.bashrc
  • /etc/enviornment
  • /etc/profile.d/

Where else should I look and how to remove this?

Best Answer

This is because you have installed jayatana that enables global menu support for Java swing applications in Ubuntu. There are few ways of doing this:

Option 1: Remove jayatana package

sudo apt-get remove jayatana

If you do not need global menu support for Java swing applications, you can simply remove the package. Removing the package will not cause more harm than making menus of java swing based applications such as eclipse and intellij move back inside the window of the application.

Option 2: Remove only the annoying message

sudo rm /usr/share/upstart/sessions/jayatana.conf

This will remove the auto-start configuration of Jayatana and you won't see the annoying message ever. Again, this will disable the global menu support of Java Swing applications.

If you want to still get enable the global menu support without getting the message, you can refer to this page. In summary:

For IntelliJ IDEA & Android Studio:

#For 32-bit Ubuntu, assuming Android studio is installed in /opt/android-studio/ 
sudo gedit /opt/android-studio/bin/studio.vmoptions 

# For 64-bit Ubuntu, assuming Android studio is installed in /opt/android-studio/ 
sudo gedit /opt/android-studio/bin/studio64.vmoptions 

At the end of the opened file, add the following line and save the file.

-javaagent:/usr/share/java/jayatanaag.jar

For NetBeans:

Assuming NetBeans is installed in /usr/local/netbeans-8.0.2

sudo gedit /usr/local/netbeans-8.0.2/etc/netbeans.conf

Search for netbeans_default_options in the opened file, and add the following statement at the end of the existing value (Notice that the options are separated by space) and close it.

-J-javaagent:/usr/share/java/jayatanaag.jar