Deploy with Java Web Start

Hi
I want to deploy my application using JWS

The problem is, apparently you can only “launch” the program
what i want is to “install” my application in a directory chosen by the user, so that

  • the user has a working directory
  • the user is able to launch local the application with a Jave VM supporting jogl without having to dl the jar each time

my problem was that when i tried my application through jws i was unable to open file given a relative pathname (ie ./myFile.txt) but maybe it’s just the gui that is not responding well…

maybe i misundertood what can/can’t be done with jws (and i think it is the case), so does someone know about a good jws tutorial ?? or a workaround to install applications instead of launching them

i’m sorry, even after reading my post twice, i still find my ideas are a little messy

JWS has the ability to “install” to the extent that an icon exists and can be run in offline mode. However, if you want to get a little more complicated you can create your JWS application to actually be the installer and it could copy the JARs from the web and create the start group icons and such.

-Matt Hicks

you can use cool free java installer: http://www.izforge.com/
so make your application, add to this instller and using webstart users will call it etc…

Java Web Start’s caching and desktop integration features allow an app launched with JWS to look like it’s installed and to be launched with no re-download of any jars. You can easily sign your application to get unrestricted access to the local file system, etc., but Java Web Start also provides APIs to allow limited file system interaction even when you’re running within the sandbox. See the FileOpenService example in the Java Web Start developer’s guide (linked from the Java Web Start documentation). See also the white paper linked from this page for a discussion of how to access your application’s resources (basically they should be installed in the jar file).

I’ve just now gotten my application to install and run using Java Web Start. Previously, I was unzipping a zip file and putting a shortcut to a batch file on the desktop. I could drag files and drop them on the icon to open them with my application, because the file name would be passed as an argument by the batch file.

When I drop a file on the shortcut placed by Web Start, it fails to open because the file doesn’t get passed to my main method as an argument. Is this a limitation of Web Start, or is there a way around it? I would also like to be able to double click on a file and open it with my app, which works using the batch file, but not the Web Start shortcut.

Finally, some users have scripts that call utility classes that are located in my jar files. When Web Start caches my jar, will it always be in the same accessible location?

Thanks.

You can associate file types with Java Web Start applications as of 5.0. Google for “java web start file associations”. You should probably post these web start-specific questions on the Java Web Start forum on javadesktop.org or forum.java.sun.com.

You shouldn’t rely on the location of the cached jar on disk. I’m not sure what kinds of scripts you have but they ideally would launch a JNLP file rather than pointing to the jar files directly.

Thanks for your help. I’m pretty ignorant about Web Start and just started using it because this forum recommended it. The documentation I read never addressed this topic and I didn’t know about the other forums, but I’ll check them out now.

Even having used Java Web Start for a few projects (JOGL included) I’m also pretty ignorant of its capabilities. I definitely think it is the right direction to go for deployment of Java applications, though.

One thing I noticed was that the latest NetBeans IDE is installed using an exe file. I’d expect that particular project to embrace Web Start as much as possible, so the fact that they use an exe makes me wonder if there are still some limitations of Web Start in regards to certain applications. Perhaps they just haven’t had time to convert their existing installer to Web Start.

Web Start documentation spends a lot of time on the case of launching from a web page which, at the very least, proves it is well named. Many JOGL and Java games probably fit in that category. They don’t really address how you would use it to install an office application or publishing package. I had a hard time finding a “best practices”, patterns, strategies, or complete examples for installing that type of application. Like I said, I don’t know if that’s because it’s more rare and unexplored thus far, or if it’s a fundamental limitation.

There are a lot of things that Web Start could be, but at present an application installer it is not. Check the recent discussion on java.sun.com about Web Start and you will see that Sun engineers aren’t trying to solve the problems that people actually have… they don’t think of Web Start as anything like an application installer.

http://java.sun.com/developer/community/askxprt/2006/jl0410.html

[quote]Alex Kobyakov: Can I specify a folder to install my application? Either in a .jnlp file or by user input like in other installers (plain dialog with file browser and text field with preferrable file path)?

Andy Herrick: No. Java Web Start is not really an installer, but a network launching protocol. The application may in fact be cached on the local client machine, allowing it to be run offline locally, but this is not required. In the upcoming 6.0 release, you can disable caching, and still launch applications from the net.
[/quote]
*emphasis mine

I think Sun is being extremely short-sighted… they are on the path to bungle Web Start like they did applets. They still don’t “get” that developers want to use Java on the desktop/client for more than a “thick client” to some web service.

So, if I want to get something working in the next couple of weeks, would you recommend using Web Start to launch an installer application that copied files from the jar to the hard drive? I’m sure a lot of people do this, but I wasn’t sure if it was considered the correct way.

I was searching through the site and ran across this post. Thanks Ken for the very helpfull tutorial on JWS.
So I would like to know what you guys think about using JWS for game deployment? I know some of the games featured on here use it.

What are the pros and cons of JWS for heavy weight games (games that use JOGL, J3D, JOGL, etc).

Thanks

JWS is really good for heavy weight stuff like JOGL, LWJGL, J3D etc

pro’s

  1. just one or two clicks to get an game started
  2. users doesn’t have to do anything complicated, like set up paths to native files etc
  3. user always gets latest version of game, so if you made a few changes/bug fixes users will get those and not have to re download and re install
  4. smart enough to only download the jars that have been updated and not the whole game
  5. did i mention how easy it was :), seriously i haven’t downloaded and run a java game manually for a long time

con’s

  1. biggest con is people not having java installed or at least JWS installed or properly configured!
  2. a few quirks with JWS atm that stop it from being totally perfect

Have you used the digital signature stuff? It seems like that could be used to prevent folks from hacking your game (espeically if your game is network based). Any thoughts on that?

i don’t have a digital certificate myself, however you do have to sign all your jar’s with one key before they work with jws, and if any jar is signed by a different one, then it won’t work, so you should get a little protection. (if you server is unhackable then it shouldn’t really be a problem ;D)

I know this is the wrong forum, but I couldn’t agree more that JWS should be so much more. Java is so incredibly hard to deploy and JWS could offer the solution. I think its tragic the way JWS can’t even instal the JRE off a CD on a computer without the net. It is such an obvious & basic problem.

I don’t agree with everything here http://joust.kano.net/weblog/archive/2006/04/06/why-i-will-never-deploy-with-java-web-start-again/ though he does make some good points… but is anybody listening?

How about that: http://www.java-gaming.org/forums/index.php?topic=13064.0 (i got a better version if anybody is interested).

My game (http://www.aevumobscurum.com) runs 100% through Java Webstart. You can either start it throught the .jnlp link -OR- you install the program with Install4j (windows, linux, unix, mac (thnks swpalmer!)). Install4j does NOT install the game, but runs the .jnlp file. It looks like a regular type application (it integrates into the menu etc), but it contains only a stub to run the online .jnlp file. That way, people download & install the installer once. All updates I do are automatically downloaded through javaws. I upload a new release to my online webstart directory, and everybody is up to date!

There is still the issue with the local directory to store “scenario” files. That’s solved too. When you download the javaws .jar files, one of the files (aevumobscurum-scenario.jar) contains the scenario.zip. The program automatically unpacks the scenario.zip to the user’s home directory (e.g. c:\documents and settings\user\aevum-obscurum-scenario…). That’s the code that I used. It’s executed when the game starts.

Is this cool or what ;D


    // find the scenario dir
    this.scenarioDir = System.getProperty("user.home") + "/" + System.getProperty("webstart.dir");

    // try to find scenario.zip and install if required
    InputStream inputStream;
    try {
      inputStream = ResourceHookup.getInstance().getInputStream("scenario.zip");
    }
    catch (IOException e) {
      // If no input stream, then there is no scenario.zip to be deployed!
      return;
    }
    
    // unzip file to local file system
    try {
      ZipInputStream zis = new ZipInputStream(new BufferedInputStream(inputStream));
      byte[] data = new byte[2048];
      ZipEntry entry;
      while ((entry = zis.getNextEntry()) != null) {
        String path = getScenarioDir() + "/" + entry.getName();
        if (entry.isDirectory()) {
          // create dirs if necessary
          File dir = new File(path);
          dir.mkdirs();
        }
        else {
          // create subdirs if necessary
          File file = new File(path);
          if (!file.exists()) {
            // only copy if file doesn't exist
            File dir = new File(file.getParent());
            dir.mkdirs();
            // write the file to the disk
            OutputStream outputStream = new FileOutputStream(file);
            OutputStream fos = new BufferedOutputStream(outputStream, data.length);
            int count;
            while ((count = zis.read(data, 0, data.length)) != -1) {
              fos.write(data, 0, count);
            }
            fos.flush();
            fos.close();
          }
        }
      }
      zis.close();
    }
    catch (IOException e) {
      throw new AccessException("Cannot deploy scenario into " + getScenarioDir());
    }

Very sweet. I think you guys convinced me that JWS is the right way to distribute java based games.

Now if I could only get javascript to work right in my web page…