— Alain Thiré, Thikro
Hi Alain. You cannot see your Java console window because it is running in a different Windows “Session”.
Let me explain a bit about Sessions and how they work:
When you log into your PC, Windows creates a Session for you. That Session holds your desktop and all the programs you start. All your applications (processes) run inside that Session. Think of the Session as your own private room, holding all your things.
If your wife logs in, she receives her own Session to hold all the applications she uses. Her Session is completely separate from yours and any program she starts will only be visible to her on her desktop. She gets her own private room.
When your computer starts, windows creates a special Session for all services. That is, Windows Services have their own room. And because this is the first Session created, it is named Session 0.
Now when AlwaysUp starts your application as a Windows Service, it launches it in Session 0 (the home for all Windows Services). And because you are logged into a completely different Session (perhaps Session 1 or Session 2), you will not be able to see your application’s windows on your desktop. Your Java application isn’t in your room.
But fortunately that is not the end of the story. Here are three ways to see what Java is printing to the console.
Solution #1: Temporarily Switch to Session 0
Windows gives you the opportunity to view the Session 0 desktop whenever a window is displayed there. Click View the message when the Interactive Services Detection alert pops up:
AlwaysUp allows you to access Session 0 at any time. Simply select
Or click the “monitor” button on the toolbar to do the same:
Now be warned — Session 0 is a strange looking place! You won’t see a task bar, desktop icons or the familiar start button. Here is what the austere Session 0 looks like with Notepad running:
Click Return now to revert to the safety of your normal desktop.
Solution #2: Restart your Java application in your Session
A second way to view the Java window is to have AlwaysUp restart your Java application in your login session. Select Application > Restart in this session to have the console appear on your desktop, alongside your other windows:
AlwaysUp will automatically return your application to Session 0 after you log off (or you can return it manually).
The obvious downside of this approach is that your application has to be stopped. Might a brief interruption cause problems? If so, restarting in your session may not be the solution for you.
Solution #3: Capture the Java console output to a file
The final solution reframes the problem. Instead of seeing the Java console window, is viewing the text printed in the window good enough?
If so, setup AlwaysUp to capture the console output to a text file. Activate the option and specify the full path to the log file on the Extras tab:
Simply open the text file to see what Java has printed to the console. Or even better, use a free “tail” utility to follow the file’s additions in real time. Both Powershell’s Get-Content cmdlet and Tail for Win32 have worked well for our team.
Best of luck with your Java application/service!