Global Menu Support for Java Applications in Ubuntu

Java swing applications' menus do not integrate with Ubuntu's global menu. A library called Jayatana is available to enable global menu support for Java swing applications in Ubuntu (From Ubuntu 15.04 Jayatana became a default library but it is disabled since 30-09-2015). There are hundreds of articles available about Jayatana, but this article has an additional hack to remove the irritating message, printed by Jayatana.
If you already have Jayatana in your system, jump to: Remove: Picked up JAVA_TOOL_OPTIONS Message

If you have not noticed any differences between Java swing applications and others, have a look at the following screenshots of Android Studio and Eclipse.

Android Studio without global menu support

Eclipse with global menu

To enable the global menu support, install the Jayatana using following commands in your terminal (Ctrl + Alt + T to start terminal).
sudo add-apt-repository ppa:danjaredg/jayatana
sudo apt-get update
sudo apt-get install jayatana
Once you have successfully installed the software, logout and login to the system again. Now open any Java swing application, you will see the difference.



Remove: Picked up JAVA_TOOL_OPTIONS Message
Now open your terminal and enter the following command to check the version of Java.
java -version
You will get a message “Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar” just above the version information of Java.
Since there are some applications which use the java -version command to check the version of installed Java, Jayatana is disabled in Ubuntu 15.04 and 15.10. If you are using Ubuntu 15.04 or latest version, ignore the Step 1 and continue from Step 2.

The “Picked up JAVA_TOOL_OPTIONS” message can be removed by a simple hack, but with a cost of disabling automatic support of Jayatana for all the Java applications. Lets dirt your hands...

Step 1:
Enter the following command in the terminal to remove the “ Picked up JAVA_TOOL_OPTIONS: -javaagent:/usr/share/java/jayatanaag.jar” message of Jayatana.
sudo rm /usr/share/upstart/sessions/jayatana.conf
Now logout and login to the system and execute the same command to print the version of Java.
java -version
This time you will not get that annoying message. But, if you run any Java swing application, it will be returned to its old swing menu. Now you need to enable the global menu support for all the Java swing applications manually.

Step 2:
IntelliJ IDEA:
To enable the global menu support for IntelliJ IDEA, enter the following command in terminal. This command is given for IntelliJ IDEA 2016.1. Change the directory name according to the your version (IntelliJ IDEA 15 does not support Jayatana).

For Ubuntu 32bit:
gedit ~/.IntelliJIdea2016.1/idea.vmoptions
For Ubuntu 64bit:
gedit ~/.IntelliJIdea2016.1/idea64.vmoptions
At the end of the opened file, add the following line and save the file.
-javaagent:/usr/share/java/jayatanaag.jar
After the modification, the file should look like this:


For all the IDEs based on IntelliJ IDEA like PhpStorm, PyChram, etc, you can apply the same technique (The vmoptions file name may be different).

Android Studio:
Android Studio users, enter the following command in your terminal:
This command is given for Android Studio 1.4. According to your version change the directory name.

For Ubuntu 32bit:
gedit ~/.AndroidStudio1.4/studio.vmoptions
For Ubuntu 64bit:
gedit ~/.AndroidStudio1.4/studio64.vmoptions
Add the following line in the opened file and save the file.
-javaagent:/usr/share/java/jayatanaag.jar
After the modification, the file should look like this:


NetBeans:
To enable the global menu for NetBeans, enter the following command in the Terminal. In my case the NetBeans is installed in /usr/local/netbeans-8.0.2 directory. Change the location in this command, based on the version and location of your NetBeans.
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)
-J-javaagent:/usr/share/java/jayatanaag.jar
After the modification, the file should look like this:



Step 3:
Close the file and open your IDE (Android Studio/IntelliJ IDEA or NetBeans), you will see the magic.


For any Java swing applications, use the following command to enable the global menu integration.
java -jar -javaagent:/usr/share/java/jayatanaag.jar <file-name>

If you are using any other Java swing applications, change the configuration file of them by adding the command line parameter '-javaagent:/usr/share/java/jayatanaag.jar' to enable the global menu.
Previous
Next Post »

16 comments

Write comments
Lucas Grigolon Varela
AUTHOR
July 7, 2015 at 8:38 PM delete

Great tutorial. Can you explain how to make the step 2 for NetBeans (8.0.2)?

Reply
avatar
Gobinath
AUTHOR
July 9, 2015 at 7:27 PM delete

Hi, Lucas Grigolon Varela,
Welcome to Java Helps. The article is updated for NetBeans. Check the Step 2.

Reply
avatar
Lucas Grigolon Varela
AUTHOR
July 9, 2015 at 10:12 PM delete

Thank you, but it doesn't work yet. LOL :(

The only difference between your tutorial and my computer is the NetBeans folder location: /home/lucas/netbeans-8.0.2/etc. I've changed the file netbeans.conf with the comand -J-javaagent:/usr/share/java/jayatanaag.jar After the word true in the netbeans_default_options and put a space between them.

Reply
avatar
Gobinath
AUTHOR
July 10, 2015 at 6:30 AM delete

Could you please share the netbeans.conf file. I hope you have installed Jayatana already. Did you check it with IntelliJ or Android Studio?

Reply
avatar
Lucas Grigolon Varela
AUTHOR
July 29, 2015 at 2:48 AM delete

Sorry for the delay, I formatted the computer and now I tried again and it worked. Thank you very much. Until now was the only solution that worked.

Reply
avatar
Ivan
AUTHOR
January 24, 2016 at 2:16 AM delete

This just don't work from me. I using Ubuntu 15.10 JDK 1.8 and Idea15. But after open settings on menu once, after that i don't open another menu.

Reply
avatar
Gobinath
AUTHOR
January 24, 2016 at 6:22 PM delete

Hi Ivan, I also checking that problem. For IntelliJ IDEA 15.10 and 15.20, I have the same problem. I am trying to find the fix for it. Once I find the solution, I will update it here.

Reply
avatar
Youri van Mill
AUTHOR
February 16, 2016 at 12:54 AM delete

I have the same issue, did you found a solution?

Reply
avatar
Gobinath
AUTHOR
February 16, 2016 at 8:04 AM delete

Hi,
In the IntelliJ IDEA release news, they have answered for this problem. IntelliJ IDEA 15 does not integrate well with Jayatana and I hope they will solve it soon.
I have attached the comment of "Alexey Ushakov" in: https://blog.jetbrains.com/idea/2016/01/intellij-idea-15-0-3-update-is-available/
Even his solution does not work.

Reply
avatar
Youri van Mill
AUTHOR
February 17, 2016 at 4:34 AM delete

Now i am using openJDK.

Installed https://download.jetbrains.com/idea/ideaIU-144.3891.8-no-jdk.tar.gz from the Early Access Program to /opt.

Added -javaagent:/usr/share/java/jayatanaag.jar to idea64.vmoptions.

The problem is gone, maybe you can try it?

Reply
avatar
Youri van Mill
AUTHOR
February 17, 2016 at 4:36 AM delete

Now i am using openJDK.

Installed https://download.jetbrains.com/idea/ideaIU-144.3891.8-no-jdk.tar.gz from the Early Access Program to /opt (without custom jdk)

Added -javaagent:/usr/share/java/jayatanaag.jar to idea64.vmoptions.

The problem is gone, maybe you can try it?

Reply
avatar
Gobinath
AUTHOR
February 17, 2016 at 7:13 AM delete

Thank you for sharing this. I will give a try and let you to know :)

Reply
avatar
Alexey Ushakov
AUTHOR
February 18, 2016 at 9:53 PM delete

Could you try the latest IDEA 16 EAP, we've fixed the main issue with Jayatana (https://youtrack.jetbrains.com/issue/IDEA-69424)

Reply
avatar
Gobinath
AUTHOR
February 19, 2016 at 4:08 PM delete

I have tested it in Ubuntu 14.04 with Oracle JDK 1.8. IntelliJ IDEA 16 EAP supports global menu :) . Thanks Alexey for sharing it.

Reply
avatar
Ondřej Fibich
AUTHOR
April 25, 2016 at 11:38 AM delete

Thanks working with Oracle Java 8, NetBeans 8.1 and Ubuntu 16.04 as well.

Reply
avatar

Contact Form

Name

Email *

Message *