Ubuntu – How to create a .desktop file to launch eclipse

desktopeclipse

When I create a .desktop file to launch eclipse (latest build with JDK 1.8 support) I get the following error:

A Java Runtime Environment (JRE) or Java Development Kit (JDK)
must be available in order to run Eclipse. No Java virtual machine
was found after searching the following locations:
/home/dean/bin/eclipse-standard-luna-M5-linux-gtk-x86_64/eclipse/jre/bin/java
java in your current PATH

Why does it try to find the JRE under the directory where the eclipse binary is?

I can launch Eclipse from the command line, and I can pin it to the launcher and it works. Why is the .desktop file so confused about what it is supposed to do?

Here is my .desktop file:

[Desktop Entry]
Version=1.0
Name=Eclipse JDK 1.8
Comment=Eclipse
Exec=/home/dean/bin/eclipse-standard-luna-M5-linux-gtk-x86_64/eclipse/eclipse
Icon=/home/dean/bin/eclipse-standard-luna-M5-linux-gtk-x86_64/eclipse/icon.xpm
Terminal=false
Type=Application
Categories=Utility;Application;

The problem I'm having is not what was asked in the question linked above as a duplice. My issue is because my PATH to the JDK is set in my .bashrc.

Best Answer

I had the same problem.

The next eclipse.desktop file works in Ubuntu 14.06 x64.

[Desktop Entry]
Encoding=UTF-8
Name=Eclipse
Comment=Eclipse IDE
Exec=/home/ivan/Eclipse/eclipse -vm /home/ivan/java/jdk1.7.0_25/bin/java
Icon=/home/ivan/Eclipse/icon.xpm
Categories=Application;Development;Java;IDE
Type=Application
Terminal=0

I didn't modify the eclipse.ini

Another solution is to modify the eclipse.ini file without modify your eclipse.desktop

My eclipse.ini:

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20130327-1440.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.gtk.linux.x86_64_1.1.200.v20140116-2212
-product
org.eclipse.epp.package.standard.product
--launcher.defaultAction
openFile
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
-vm
/home/ivan/java/jdk1.7.0_25/bin/java
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-XX:MaxPermSize=256m
-Xms40m
-Xmx512m

The -vm option and its value (the path) must be on separate lines.

More info: Wiki eclipse.ini

Related Question