How to make /etc/init.d script act like it's launched under X?

view full story

http://unix.stackexchange.com – I'm trying to track down some quirkiness with a Java application that misbehaves when launched via a startup script in /etc/init.d , but runs fine when you open a GUI terminal window and run it through /etc/init.d/myapp start. (The quirkiness involves a portion of the app that does some hacky handwaving with X.) Since the app runs fine when launched via a terminal window, I'm looking at how it's launched before I dive into (admittedly delicate and not my) source code. The answer at this post gave me a clue that the Gnome terminal is running inside a window manager, which is somehow affecting (HowTos)