views:

15

answers:

2

I am building an applicaton in Java that will have some updates over time. This means that the client will have to download a new .jar and use it when available. I read about jws (java web start) and it works fine. But the problem is that my application uses a protocol I created, and it will just be able to connect to my server. It may not have connectin to internet and I should not be able install a web server on that server. So is there a way I can use JNLP inside my own proto? Or I will have to do it all by myself?? Making it download a new jar and deleting the old one?

A: 

If your application is based on Web Start, it will automatically perform the updates. However, this only works for known protocols, such as HTTP (and maybe FTP, but never tried that). I don't think you will get Web Start working with your own protocol, but you could try to do it with a custom URLConnectionFactory and roll your own connection handler for your protocol. See java.net.URL.setURLStreamHandlerFactory(URLStreamHandlerFactory)

Anyway, I'd go with a custom update implementation in this case, as you requirements seem to be very specific. Since your app doesn't seem to be based on an existing framework with update mechanisms (e.g. Eclipse RCP with P2 manager or NetBeans or Java Plugin Framework or Maven ...).

mhaller
yea seems like a good idea going for a custom update. But how would it work? I should just download the new jar, and replace it?
fredcrs
Replacing jars which are in use does not work on Windows afaik. You have to put them into a separate place, shutdown the application and then move them to their destination before restarting the app. Alternatively, you could try to implement your own plugin mechanism. Btw, OSGI does what you want and can install new bundles at runtime :) not sure if you wanna rearchitecture your app and use OSGI though.
mhaller
A: 

The problem is how to get the files needed to start your application downloaded to Java WebStart, and if all you have is your proprietary protocol, then you don't have anything on the machine running Java WebStart which can talk the protocol so you cannot get anything downloaded.

In other words, you need a web server somewhere for Java WebStart to work well.

(I do not consider the "seed the JWS cache" to be a viable option if there is no server)

You can, however, easily create a Google Application Engine application which can provide the files for your application, and that is enough for Java WebStart (plus enclose some configuration that allows for the program to know where to contact your application).

Thorbjørn Ravn Andersen