I have a Java 1.6 desktop application, started with javaw from a batch file on Windows XP. There is a .lnk link to this batch file, which is placed to windows Startup folder in order to start this application on every system boot.
The application uses SystemTray class to display an icon on the system tray in case it is running. Starting this application manually there is no problem. If it is started by windows startup process, there is no icon displayed (not even a blank icon), however the application is running. The startup process is also slowed down.
How can I overcome this?
Thank you!
Are you starting the Java application on system boot or on user login? If you start the application before a user is logged in, there will probably be no system tray to attach to, since the system tray is associated with the user session.
If you don't need the Java application to be running before a user is logged in, it might help to move the shortcut to the user's (or all users') autostart folder.
Related
I installed my program in a Jar file as a Windows Service using Apache Procrun.
When I run it using the command start "prunsrv.exe //TS//TestService" it runs perfectly. But when I start the service in Windows services program, it doesn't launch the JFrame.
Yet the application does start as I can see the log entries. But related to the JFrame section, there are no exceptions yet it doesn't launch. Why does it not launch?
Your service is not permitted to use the desktop, if it does not run as the current user (the owner of the desktop).
If so, the first call to Dialog.open() or other methods which paint on the desktop just hangs.
I have a common question, how it is possible to launch a Third-Party application in Java, without to open it in the desktop (start the application as process?). I stuck at this point, so is there a way to open an application in an "hidden" mode.
OS: Windows Server 2008
As Ronald said, you can create a batch file to start the third party application in the background. Add the batch file to the windows services startup in automatic mode. This is the easiest way you can make it run at startup in the background
I am trying to run a Windows app (a window with UI and sounds). I've changed Tomcat service to be opened using the same windows user as the one that logged in to the machine.
When I run this, the app is started, I can even hear it sounds, but no window is visible.
How can I fix this?
I have created a Java application which needs to run as a service. For service wrapper I tried using tanuki and other wrapper softwares.
Now, my application does run as a service - however, it runs as a service under SYSTEM and not under currently logged in user.
My application has a UI, which does not show when the application is running as a service. I doubt that this has happened because the service is running under SYSTEM and not under currently logged in user.
When I run the application (without installing it as a service), the UI does show up and I could see the java process running under the current user's id, whereas it runs under SYSTEM when installed as a service.
Now, there is nothing to my application if there is no UI. I need to application to run as a service when the system boots up and the UI needs to show up as well.
Has anyone tried to do what I am doing here and has faced a similar issue. If so, how did you go about resolving it?
Is there a different wrapper service that I could use and not have this issue.
Tanuki's documentation does explain setting a java application as a service, but does not talk about a java applicaiton with a UI and running it under the currently logged in user.
Update
Just so that folks here could get a bit more idea as to what is it that I am trying to accomplish - the behavior that I am trying to have with my app is similar to how Dropbox or Yahoo Messenger or any other software has which starts with Windows boot and continues to run in the background, allowing the users to interact with it using the system tray icon. So basically all of this has been built in Java/Swing. Now when it has come to deployment of the app - I can run it standalone but running the jar file or by creating and running an executable wrapper for it. However, I want the software to start with Windows boot and continue to run as a service in the background, while allowing the user to make changes and interact with it via lets say bringing up the UI from a system tray icon that it sets.
As of now, it does run as a service successfully. It performs all the actions that it ideally should - there just is no system tray icon to bring up the UI and make changes to its configuration.
Update - 2
Ok.. I tried advanced installer and it does wrap up everything for me to generate an exe installer for windows. Now all I need is to auto-start the software. Can anyone help me with this? I don't see an option in Advanced installer to automatically have the program add itself up in the auto-start.
Link to tanuki's doc http://wrapper.tanukisoftware.com/doc/english/faq.html
Rohan,
Please take a look at the following page:
http://wrapper.tanukisoftware.com/doc/english/prop-ntservice-interactive.html
You will need to mark the Service as interactive and then run as the SYSTEM user in order to get your GUI to show up on the first logged in desktop.
The problem is that Microsoft changed what services are allowed to do starting with Windows 2008 and Vista. This means that starting with these versions, the GUI will always show up on a sandboxed desktop which the user will need to switch over to.
If you want to show a GUI on all desktops, in all versions of Windows, you will need to run the JVM within the desktop.
Cheers,
Leif
I wanted to comment on your question, but I don't have enough reputation to do it. So I'm misusing the answer function now.
I have a similar problem. I used the tanuki wrapper for a while now on a Windows XP machine and the Swing GUI was shown to all users who logged in.
Now I migrated to Windows 2008 Server and configured the current version of the tanuki wrapper like this:
wrapper.ntservice.interactive=true
wrapper.ntservice.hide_console=true
(see documentation here and here)
The Windows service runs under the LOCAL SYSTEM account.
But the GUI is still not shown. Did you find any solution to the problem?
Don't think you should have a UI with a service. Put it in the startup group instead ?
What's does the UI and application do?
I have developed a Java aplication that is currently being run by double-clicking on a ".bat" file that does something like "java -jar proy.jar". This application just listens on a port and writes to a database, so it does not have any user interface (such as a window). I need this application to run as in background mode, or as it were a service, but I don't really anything more than that. It's enough if the application is run in a way that is not noticeable by the user, so that the user is not bothered and so the application can not be mistakenly closed. By the way, this will be run on an specific computer so it's okay if I have to do any manual configuration ir order to make this work. Also, I need this application to run on startup.
Any help/tips regarding this?
In advance, thank you very much for your help!
Regards,
Pedro
use javaw.exe instead of java.exe and you will not get a console window.
from the java.sun.com:
The javaw command is identical to java, except that with javaw there is no associated console window. Use javaw when you don't want a command prompt window to appear. The javaw launcher will, however, display a dialog box with error information if a launch fails for some reason.
EDIT:
A .bat will start a console. If you can live with a console up for a fraction of a second, you can preface your call to javaw with start. This will spawn another console-less process for javaw and allow the console-ful bat to exit.
You can run your application as a System Tray icon (Java 1.6) if you are targeting Windows environment. Allow a context-sensitive menu trigger when clicking on the System Tray icon for the user to select a few options.