Sunday, May 27, 2012

Custom Launcher for IntelliJ IDEA in Ubuntu Unity

IntelliJ IDEA does not install a program launcher during installation. You only get a start-up script. So you need to create a custom launcher to quickly and easily run the program without going to the terminal.


In previous versions of Ubuntu we had this to quickly create a launcher.


But in Unity it is not so easy.


For IDEA, first you have to specify the location of Java by inserting the following line in the idea.sh file in the bin directory of IDEA installation location.
IDEA_JDK=/usr/local/lib/java/jdk
Next you have to create a custom launcher.

For IntelliJ IDEA 11 or later

If you have IntelliJ IDEA 11 or a newer version, things are pretty easy. Just run IDEA, then go to Tools menu and select Create Desktop Entry. A launcher will be created at ~/.local/share/applications and you will be able to access it through the Dash. You can pin it to the launcher bar by right clicking on the icon when it's running or by drag and drop of the icon.

For older versions

This method can be used to create a launcher for any application, not just IntelliJ IDEA. For any launcher in Unity what you need to create is a .desktop file.

First create a file named idea.desktop in your home folder. Then open it with a text editor and add the following to it.

[Desktop Entry]
Name=IntelliJ IDEA
Comment=IntelliJ IDEA IDE
Exec=/home/nufail/apps/idea-IC-107.587/bin/idea.sh
Icon=/home/nufail/apps/idea-IC-107.587/bin/idea_CE128.png
Terminal=false
StartupNotify=true
Type=Application
Categories=Development;IDE;

nautilus-actions.org gives a good explanation about .desktop files and what all these entries mean and other entries available for .desktop files.

Now you can keep this file in the Desktop to use it as a desktop launcher or you can add it to ~/.local/share/applications to access it through the Dash for only the current user. If you need to access it through the dash for all users, then add it to /usr/share/applications

14 comments:

Unknown said...

thanks !

Johnny Noodles said...

The process for IDEA 11 also works for IDEA 12.

Mohamed Nufail said...

Thanks Johnny. I've updated the post to include it.

X said...

Thanks!

Unknown said...

Thank You Mohamed, your tip really help me.
Am on Ubuntu 13.04 (Unity) and I install the IntelliJ Idea 12 on it and followed your trick to have the launcher.

Thanks again :)

Luis said...

Thanks!!

Rashendra said...

Ibrahima Ciss
I am having ubuntu 13.04 and tried to launch the desktop launcher with that... but does not work..
Please help, Says NO valid
"No JDK found. Please validate either IDEA_JDK, JDK_HOME or JAVA_HOME environment variable points to valid JDK installation."

Please help
Rashen

Mohamed Nufail said...

Hi Rashendra,

Make sure you have Java JDK installed and add the IDEA_JDK variable into the idea.sh file as follows. The variable should point to your Java installation folder.

IDEA_JDK=/usr/local/lib/java/jdk

Unknown said...

Hi there,

Nice post :)

I am having some issues thou with accessing some environmental variables in IntelliJ.
If I start IntelliJ from the bin directory I can access them, as soon as I start the IDE from the desktop icon, they are not available.

These are some custom variables which i need in my application...

Cheers,
Andreea

Mohamed Nufail said...

Hi Andreea,

This could be because of how you have set these custom environment variables.

If you've set the variables as a different user and run IDEA as that user (happens most times for root user) when running from terminal, then it may work in terminal but not with .desktop file which is run as the regular user.

If you've set the variables in a file like ~/.bashrc then those are accessible only to programs started from bash terminal. You will have to set it in somewhere like ~/.profile to access it from graphical environment. Refer https://help.ubuntu.com/community/EnvironmentVariables#Persistent_environment_variables

Thanks,
Nufail

Unknown said...

i used Exec=env JAVA_HOME=MY_JDK_PATH MY_ IDEA_PATH/bin/idea.sh to solve JDK not found problem

Dunith Dhanushka said...

Thanks! that worked well!

Tanker said...

Thanks so much! That's great!

Anonymous said...

hey links is not working...... IntelliJ IDEA Ultimate 2017.2.5

Post a Comment