13

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.

0

4 Answers 4

11

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

0
1

The output does say that it searched in the PATH too:

No Java virtual machine was found after searching the following locations:
...
java in your current PATH

You said you can launch eclipse from a terminal: In this case I would say that your java is installed to a non-standard directory, which is added to your PATH by a terminal startup script (bashrc, zshrc, etc.) but it is not added to your session when you login. So when you are in a terminal session your PATH is different from the one which is used when the .desktop file is invoked.

To troubleshoot this case:

  • To see where java is installed: which java
  • Check your ~/.profile if the correct PATH with the java directory is set in it. If the correct path is only set in .bashrc, .zshrc, etc. then it is possible that those scripts are not invoked on login, so the PATH is not set correctly. Also if you have ~/.bash_profile or ~/.bash_login you have to check those too. If you provide these files we can look into this whether this is your problem.

If you can't solve it this way, you can always modify the PATH directly in the .desktop file with env PATH= ...

7
  • That's exactly my issue then. I set the PATH to the JDK in .bashrc. Looking at the docs for a .desktop file the PATH entry seems to do something else. Is there a way to set the system PATH in .desktop? Feb 10, 2014 at 17:53
  • After some Googling I found that the solution is to change the Exec line like this: Exec=env PATH=/home/dean/bin/jdk1.8.0/bin:$PATH /home/dean/bin/eclipse-standard-luna-M5-linux-gtk-x86_64/eclipse/eclipse The docs for the .desktop file were no help. Feb 10, 2014 at 18:16
  • The same modification to the Exec=... line does not work for launching IntelliJ via the idea.sh file, however. Feb 10, 2014 at 18:20
  • @DeanSchulze Yes, Exec=env PATH= ..., that's what I meant in my last line. Normally you would like to set up PATH in .profile, not .bashrc. The .profile file is parsed by the login shell so it will set up PATH correctly when you login, and then there will be no need for the env workaround. On Debian/Ubuntu .profile sources .bashrc, so this shouldn't be a problem, but maybe your .profile is not doing it, so check it. Or you have a .bash_profile or .bash_login file which overrides the .profile settings.
    – falconer
    Feb 10, 2014 at 20:12
  • @DeanSchulze So to sum up, set your PATH in .profile (or .bash_profile or .bash_login if you have one of those files) not in .bashrc, or make sure that .bashrc is sourced by the aforementioned files. If you set it up this way, your PATH should be correct for the .desktop files too, and there will be no need for "tricking".
    – falconer
    Feb 10, 2014 at 20:13
1

I've copied the following block from within the if [ -n "$BASH_VERSION" ]; then statement:

if [ -f "$HOME/.bashrc_" ]; then
    . "$HOME/.bashrc"
fi

I've also tried without the if statement:

. "$HOME/.bashrc"

but Eclipse fails with the same error message in both cases. Apparently HOME isn't set when lightdm runs ~/.profile.

Explicitly setting the path in ~/.profile works, but I want to keep my PATH and my other Bash features (aliases, functions) in the same file.

The solution is to set the PATH on the Exec=env PATH=$PATH:... line in eclipse.desktop. Nothing I've tried works to start IntelliJ from a desktop icon, however.

Given that you are reinventing the Linux GUI experience with Unity maybe it's time to leave the error prone series of scripts behind and use something that is less error prone and easier to use. The scripts would still have to be there for bash shells, but the Unity desktop could be independent of them.

1

I have a very simple method.

Open Gedit or Text Editor. Add:

[Desktop Entry]
Exec=/home/testrule/eclipse/eclipse
Icon=/home/testrule/eclipse/icon.xpm
Type=Application

Save in desktop as eclipse.desktop.

Right Click on the eclipse.desktop file > click properties > click Permissions tab >> Click the check box of Execute

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .