We help IT Professionals succeed at work.

Java Application Not Loading GUI when started from task scheduler

R0y4L
R0y4L asked
on
Hi Experts,

I have confusing situation. So: I have a big server application on a server which restarts every morning. There is a scheduled task created which will runs a .exe of the server application after the machine has started up. The problem I am getting is that the server application runs in as a process, but I cannot display GUI for it. Now the only way to display GUI is through a system tray icon which appears only if i start up the program by double clicking the .exe file.

Could any one explain to me why the system tray appears if I manually start the program, but does not if the program is started by a scheduled task? Or how could I make the GUI to be usable when it is started from the scheduled task.

Thanks
Comment
Watch Question

Awarded 2011
Awarded 2011

Commented:
I'm not sure I understand where does java come in here.
What is the server that you are talking about.

Author

Commented:
Well the "server" is the server application written in java.
Awarded 2011
Awarded 2011

Commented:
How is it packaged in .exe ?

Author

Commented:
Using launch4j program. The only thing that the .exe does is copy a reference of the Server.jar file into the jre folder in ProgramFiles/Java location and execute command java -jar Server.jar
Awarded 2010
Top Expert 2013

Commented:
If it's running the scheduled task as a service or under a different user name or as a hidden task, then any one of those would cause the GUI to not show up.
Awarded 2010
Top Expert 2013

Commented:
A lot of server applications are set to run as services in which case there is no way for them to directly communicate with the user session.

Author

Commented:
It is running as a different user. However, If I log in as the the same user it still does not show up. It runs as a process and is not hidden.
Awarded 2010
Top Expert 2013

Commented:
You are using Windows Task Scheduler to run it, yes?

Author

Commented:
Yes
Awarded 2011
Awarded 2011

Commented:

Trye if user is logged in checkvbox - at least for a try

In practice I find if I have "Run only when user is logged on", the task runs in the system tray as required, but it only works if I am the user logged in.

If I select "Run whether user is logged in or not", the task runs as a background process (a daemon in Unix terms) with no user interface, no use at all.
Awarded 2011
Awarded 2011
Commented:
>Trye if user is logged in checkvbox - at least for a try

I mean the checkbox on Task Scheduler - did you try to have it checked?

the quote above is from:
http://social.technet.microsoft.com/Forums/eu/w7itprogeneral/thread/f79c7733-341a-404d-8309-fa5a3f82b293
Awarded 2010
Top Expert 2013

Commented:
Yes. You can't have it set to run as a process or it will run in the background.

Author

Commented:
Is the actually a solution out there which would allow me to start my server application when the machine starts up automatically and allow me to use GUI?

Thanks
Awarded 2010
Top Expert 2013

Commented:
You can just put a link to your application in the Startup folder.

Author

Commented:
But, does it not require for someone to log in for the .exes in the Start up folder to be executed?
Awarded 2010
Top Expert 2013
Commented:
Yes. Someone would need to log in for any GUI to pop up too. You can set the computer to automatically log in as any user at startup. You just need to put the username and password in the registry. At our shop we have a softwareStartup account that logs on automatically to all the servers but has limited access to do much else.

Author

Commented:
I've split the points between the two experts as they took time to reply even though there is no real solution to my problem. Thanks again.