Install and uninstall a java application in ms-windows - java

I have created a java application.
I also created another java application which install the first application.
The program runs perfectly.
However the program isn't displayed in control panel->programs.
I also want to create an uninstaller (let's say unintaller.bat). But i want to works like any other uninstaller. When someone goes to Control Panel->serach program->uninstall this program it will run the uninstaller.bat
In other words, the concept is how to declare the java application in windows...
Any idea???

Installing an application doesn't necessarily mean registering it with the operating system. For example, for a Mac, I can open an App without having it added to the Applications folder.
Same with Windows. Just because a new file can be added to the Start menu, it doesn't mean it was registered.
Use a Windows installer. There are tons that are open source, and even MS provides a free one: http://support.microsoft.com/kb/942288.
This will allow you to install an uninstall an application using standard tools. Yes. It can be called from a bat file.
Java open source installers: http://java-source.net/open-source/installer-generators

Related

What is i4jdel.exe doing in EXE4J-wrapped java-applications?

If I run a java-application wrapped in EXE4J to make native Windows app then on the startup it will create and run an executable called i4jdel.exe from within user's temp-folder. Unfortunately, some antiviruses classify this program as malware.
What this i4jdel.exe is really about? What does it do, and, most importantly, are there any official sources confirming its genuineness?

Run Jar file on startup?

I have a Java application that lives in the system tray that I compile to a executable jar file. I would like to add the option within my program to add to the system startup items.
As I do not know of any uniform way to do this for all operating systems I assumed I would have to write code to do it for each one I intend to support so I started with Windows.
When I attempted to add it to the registry at [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Run] using the code available here I discovered that under Windows 7 and 8 unless I have administrator privileges (by running from an elevated command prompt) my edits to the registry do not apply.
Then I spent a day trying to figure out how to get the Jar to relaunch itself with admin privileges before I gave up on that hacky workaround.
Can the task I'm trying to achieve even be accomplished and if so how?
For the most part, you're actually looking to add the feature of auto starting on user login, rather than on system startup. For windows, if you add the registry entry under:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run
This location does not suffer from permissions issues when run as an ordinary user, and has been supported for a long time under Windows (I'm thinking Windows 95 time frame here), so should be a safe change across all systems.
For Linux, assuming that the operating system is following the Open Desktop AutoStart specification, then you need to create the appropriate .desktop file in $HOME/.config/autostart/ and it should autostart on login in that case.
For Mac OS X, you need to create a launch agent plist in $HOME/Library/LaunchAgents. The Daemons and services documentation details how to construct this file.
Working around user privileges is not a good idea. The registry entry is the preferred way to go. Also keep in mind that the jar by itself is not executable, it requires the jvm, so what you might want to do is use a wrapper and register that.

Java service wrapper to create service for Java UI application

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?

Any way to have Java Web Start automatically install shortcuts?

We're deploying a Web Start app that I and the other developers know how to install the shortcuts for (Control Panel -> Java on Windows, /Applications/Utilities/Java Preferences on OS X), but we have no reason to believe that end users know how to do this (or even know that it can be done).
Is there a way to either install the shortcuts automatically on first run, or (much preferably) ask the user if they'd like to install the shortcuts? I've been looking all over but the Sun/Oracle docs all say to go through the Java cache viewer, which I find completely ridiculous to ask of end users.
The JNLP specification allows for specifying that short cuts are to be created when the JNLP file is run.
Check the <jnlp><information><shortcut> tag.
The javaws command states:
Usage: javaws [control-options]
control-options include:
....
-import [import-options] <jnlp-file> import the application to the cache
import-options include:
....
-shortcut install shortcuts as if user allowed prompt
so you could probably do it through an invocation of javaws.
As of 1.6.0_18+, JWS offers the IntegrationService.
The IS can not only install/uninstall desktop shortcuts and menu items, but will report the success or failure of attempts to create/remove them.
Some minor points on standard use of shortcuts (through the JNLP file) using Windows and Linux. JWS will prompt the user only if the app. is sand-boxed. If the app. is trusted, it will go ahead and attempt to create the shortcut.
On Ubuntu Linux the menu items will fail silently, but the desk-top shortcut works. I have been meaning to investigate whether Ubuntu menu items will work better using the IS, by targeting the sub-menu to one of the standard sub-menus offered. If that is the case, menu items might be installed by the application targeting different menu structures on different OS'.

Make WebStart Java desktop application to start on system startup on Windows and Mac

I developed small cross-platform (Windows and Mac) SWT desktop application. It is distributed with WebStart. So far so good, everything works.
I've got a new requirement to make my app start on system startup (with no user interaction). What is the best way to accomplish that?
In JNLP file I've got this:
<shortcut online="false">
<desktop/>
<menu submenu="CompanyName"/>
</shortcut>
On Windows WebStart creates a desktop link [app_name].lnk and it points to
javaws.exe and then some Java cache file as a parameter with funny name like ..\Sun\Java\Deployment\cache\6.0\4\2c0a6a781-213476. I can possibly programmatically find that link on user's machine by name... erm... and then copy it into user's Startup folder. I can see a problem here though as user can disable WebStart desktop shortcut creation option all together.
On Mac WebStart pops up a dialog to prompt user for the location where to create an [app_name].app (user is allowed to change link name there!) file that launches an application. On Mac I don't event know where the Startup folder is located (and it seems to be much more complex there).
Is there Java library out there that abstracts start app on system startup concept on different platforms as SWT does for GUI abstraction?
There is, but it's very new, so it's not widely available.
The IntegrationService was introduced in 1.6.0u18. The method of interest is requestShortcut.
You can take a look at Java Service Wrapper. This can wire your program as a windows service.
Bump!
Seems like http://yajsw.sourceforge.net/ is the currently active project that achieves this.

Categories

Resources