Set variable in .desktop file

You can add an environment variable to an application by editing its .desktop file. For example, to run "digiKam" with the environment variable APPMENU_DISPLAY_BOTH=1, find the corresponding digikam.desktop file and add the setting of the variable, via the env command, to the entry "Exec":

Exec=env APPMENU_DISPLAY_BOTH=1 digikam -caption "%c" %i

In your case:

Exec=env GTK2_RC_FILES=gtkrc.custom /path/to/eclipse

An alternative to modify the .desktop file is to put a wrapper script in e.g. ~/bin.

$ cat ~/bin/eclipse
#!/bin/sh
export GTK2_RC_FILES=gtkrc.custom
exec /usr/bin/eclipse "$@"

This way the customization won't be overwritten next time the application package is updated.

Edit:

A hint about why this works can you see by checking out what the PATH variable contains. In my case:

$ echo $PATH
/home/gunnar/bin:/home/gunnar/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

~/bin is the first folder in the list, and thus is looked at before /usr/bin.