2

I have a Java application which is launched by a shell script. The first part of the shell script is to resolve the Java location by looking at $JAVA_HOME.

The shell script is working well if launched from the terminal but it fails if launched by double-clicking the .desktop file which contains the following

Exec=/bin/sh "/opt/HO/HO" %U 

Looking at the logs it seems the error occurs because $JAVA_HOME returns nothing when the script is launched that way.

I tried to replace /bin/sh by /bin/bash but it also fails.

Any idea why environment variables are not found that way? What should I do?

3

1 Answer 1

6

From the Ubuntu documentation 1:

Shell config files such as ~/.bashrc, ~/.bash_profile, and ~/.bash_login are often suggested for setting environment variables. While this may work on Bash shells for programs started from the shell, variables set in those files are not available by default to programs started from the graphical environment in a desktop session.

Hence, the fix was to declare $JAVA_HOME in .profile and to log in again.

(thank you @plumo, for pointing me into the right direction)

    You must log in to answer this question.

    Start asking to get answers

    Find the answer to your question by asking.

    Ask question

    Explore related questions

    See similar questions with these tags.