This discussion is archived
8 Replies Latest reply: Jul 10, 2011 9:25 PM by bouye RSS

Deploying Desktop Application

869206 Newbie
Currently Being Moderated
Hello,

I was tasked with creating a simple desktop application that would demonstrate certain functionality that our consultancy markets. I decided to do this with JavaFX.

Only after completing the project and getting ready to package it up do I find that apparently there is no JavaFX runtime redistributable that I can send along with the jar file. The only information I can find on actually running the application involves installing the SDK. I am certainly not going to tell our clients that they have to install a Software Development Kit in order to run this demo. It's not a web tool, it's not a phone app, it is just a simple desktop application.

I'll cop to being an idiot, who assumed that running a JavaFX desktop application would be no more complicated than the equivalent of 'java -jar'. Apparently, this only is true on a development machine.

Now, I'm looking for help in figuring out what exactly I need to send along with the tool, in order to get it to work on systems that have nothing other than a recent JRE installed. I have tried fiddling the .jnlp to get it to run locally but no joy there, either. Ideally, I would be able to ship with a simple script that would run the tool, something like 'javafx -cp .\app.jar mainclass.Main' being the goal.

Thanks for any help.

mp
  • 1. Re: Deploying Desktop Application
    857529 Explorer
    Currently Being Moderated
    This issue will be solved with JavaFX 2.0 http://www.oracle.com/technetwork/java/javafx/downloads/index.html
  • 2. Re: Deploying Desktop Application
    869206 Newbie
    Currently Being Moderated
    javafx4you wrote:
    This issue will be solved with JavaFX 2.0 http://www.oracle.com/technetwork/java/javafx/downloads/index.html
    That's not a solution. 2.0 is completely different and not backward compatible. Basically, you're telling me to throw out my work and start over from scratch.

    I can't believe I got myself into this mess. There's about 0% chance that I will take a chance on anything coming out of Oracle other than plain old Java, from here on out. In the meantime, I still would like to know if there is a way for me to salvage all the work I put into this project.

    Thanks.

    mp
  • 3. Re: Deploying Desktop Application
    JonathanGiles Journeyer
    Currently Being Moderated
    It's not totally clear whether you're talking about JavaFX 1.3 and earlier, or JavaFX 2.0, but given your choice of forum (JavaFX 1.x), and your talk about not wanting to move to JavaFX 2.0, I'm going to make the easier assumption that you're talking about JavaFX 1.x.

    As far as I know, and perhaps I'm forgetting specifics, but there is no requirement for your clients to manually install the JavaFX 1.x SDK onto their machines to run JavaFX applications. You can simply package your application and provide them with a JNLP file. This file is able to be double-clicked, and will auto-install the JavaFX runtime on to client computers the first time they try to run JavaFX. Subsequent attempts to run the JNLP file will not require JavaFX to be first installed.

    Again, I'm a little foggy, but I do believe that NetBeans will generate everything you need to deploy. All you should need to do is edit the JNLP file to remove references to your specific machine. I'm sure there are enough tutorials on Google to help you through this.

    Good luck,
    Jonathan
  • 4. Re: Deploying Desktop Application
    bouye Journeyer
    Currently Being Moderated
    Unfortunately JavaFX 1.x app install is a pain most of the time. This happened to me again last week where I had to help installing our app on a dozen laptops during a workshop and basically each laptop has had an issues that was different from the other one. And added to that issues with security settings in our network, web proxy, a wide range of web browsers not working the same way, various Java (and JWS) versions not working the same way and on top of that the usually bad internet connectivity we have here.

    I recommend you take a look at this message I've posted recently (Ive made others similar in the JWS forums but it looks like people over there found I was complaining too much about JWS wooes) : Re: Windows Executable

    The important part are:
    - You need a working Internet connection (to be able to download JavaFX 1.3 runtimes).
    and:
    One way to circumvent the issue would be to make your installer try to cache the whole runtimes by calling:
    javaws -import http://dl.javafx.com/1.3/javafx-rt.jnlp
    Mainly because JWS does that badly when launching the JNLP from your app.

    You can also have a look at the JavaFX documentation (http://download.oracle.com/javafx/1.3/tutorials/deployment_toolkit/) about deployment on an intranet, but it's not that good, especially when you have to deal with a different range of operating system (as their method only caches the native runtimes for the OS you are on) or, in our case, the fact that guest PCs connected to our network have restricted access to domain machines as well.

    Edited by: bouye on Jul 8, 2011 1:34 PM
  • 5. Re: Deploying Desktop Application
    869206 Newbie
    Currently Being Moderated
    JonathanGiles wrote:
    It's not totally clear whether you're talking about JavaFX 1.3 and earlier, or JavaFX 2.0, but given your choice of forum (JavaFX 1.x), and your talk about not wanting to move to JavaFX 2.0, I'm going to make the easier assumption that you're talking about JavaFX 1.x.

    As far as I know, and perhaps I'm forgetting specifics, but there is no requirement for your clients to manually install the JavaFX 1.x SDK onto their machines to run JavaFX applications. You can simply package your application and provide them with a JNLP file. This file is able to be double-clicked, and will auto-install the JavaFX runtime on to client computers the first time they try to run JavaFX. Subsequent attempts to run the JNLP file will not require JavaFX to be first installed.

    Again, I'm a little foggy, but I do believe that NetBeans will generate everything you need to deploy. All you should need to do is edit the JNLP file to remove references to your specific machine. I'm sure there are enough tutorials on Google to help you through this.
    Hello,

    Thanks for the reply.

    As a matter of fact, NetBeans packaging of the jnlp file doesn't do it. It builds the codebase URL based on locations of the project files in the dev machine. So, you still have to fiddle it. I did try that, actually, based on some discussions I found on how to make the jnlp work for local files. However, I could not get it to work. It would act like it was running; I even get some popups asking security questions about connecting to the internet; but the GUI never appears.

    I would not have minded making that work. But, of course, the app has to appear in a reasonable amount of time; I can't have the end user waiting a minute or more after clicking the file.

    Thanks.

    mp

    Edited by: nyambol on Jul 8, 2011 8:07 AM
  • 6. Re: Deploying Desktop Application
    869206 Newbie
    Currently Being Moderated
    bouye wrote:
    Unfortunately JavaFX 1.x app install is a pain most of the time. This happened to me again last week where I had to help installing our app on a dozen laptops during a workshop and basically each laptop has had an issues that was different from the other one. And added to that issues with security settings in our network, web proxy, a wide range of web browsers not working the same way, various Java (and JWS) versions not working the same way and on top of that the usually bad internet connectivity we have here.

    I recommend you take a look at this message I've posted recently (Ive made others similar in the JWS forums but it looks like people over there found I was complaining too much about JWS wooes) : Re: Windows Executable

    The important part are:
    - You need a working Internet connection (to be able to download JavaFX 1.3 runtimes).
    and:
    One way to circumvent the issue would be to make your installer try to cache the whole runtimes by calling:
    javaws -import http://dl.javafx.com/1.3/javafx-rt.jnlp
    Mainly because JWS does that badly when launching the JNLP from your app.

    You can also have a look at the JavaFX documentation (http://download.oracle.com/javafx/1.3/tutorials/deployment_toolkit/) about deployment on an intranet, but it's not that good, especially when you have to deal with a different range of operating system (as their method only caches the native runtimes for the OS you are on) or, in our case, the fact that guest PCs connected to our network have restricted access to domain machines as well.
    Hello,

    Thank you very much for the extensive reply. I believe you have given me exactly the information I need to avoid going out the window head first. Honestly, I was up half the night fretting about what I was going to tell my boss. He's not a bad guy, but when they're paying me to write this stuff internally ... we're not billing any client, which makes him nervous. And me. ;-)

    I'm off to put this information into practice.

    Thanks.

    mp
  • 7. Re: Deploying Desktop Application
    869206 Newbie
    Currently Being Moderated
    Hello,

    I'm even less smart than I thought I wasn't. I can't get the jnlp file to work, following the instructions at this page:

    http://download.oracle.com/javafx/1.3/tutorials/deploy-using-webstart/
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp spec="1.0+" codebase="file:///Documents and Settings/mpowe/Desktop/dist/" href="TL_DC_Demo.jnlp">
        <information>
            <title>TL_DC_Demo</title>
            <vendor>Technology Leaders</vendor>
            <homepage href=""/>
            <description>TL_DC_Demo</description>
            <icon kind="splash" href="http://dl.javafx.com/1.3/splash.png"/>
            <offline-allowed/>
        </information>
        <resources>
            <j2se version="1.5+"/>
            <extension name="JavaFX Runtime" href="http://dl.javafx.com/1.3/javafx-rt.jnlp"/>
            <jar href="TL_DC_Demo.jar" main="true" size="195522"/>
        </resources>
        <application-desc main-class="reader.Main" >
            
        </application-desc>
        <update check="always"/>
    </jnlp>
    The error generated is:
    java.lang.NoSuchMethodException: reader.Main.main([Ljava.lang.String;)
         at java.lang.Class.getMethod(Unknown Source)
         at com.sun.javaws.Launcher.executeApplication(Unknown Source)
         at com.sun.javaws.Launcher.executeMainClass(Unknown Source)
         at com.sun.javaws.Launcher.doLaunchApp(Unknown Source)
         at com.sun.javaws.Launcher.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    So, the original jnlp generated by NetBeans has a slightly different format. The critical difference is here.
    <application-desc main-class="com.sun.javafx.runtime.main.Main" progress-class="com.javafx.progressbar.ProgressManager">
            <argument>MainJavaFXScript=reader.Main</argument>
    </application-desc>
    Inserting this section in the jnlp results in ... something. Because the tool connects to an internet site when it starts up, I get two security popups from Java, asking if it's okay to connect. I click 'ok.' After that, nothing.

    So, it looks lke the app loads successfully, but the GUI never appears.

    I would appreciate any suggestions in sorting out what is happening here.

    Thanks.

    mp

    Edited by: nyambol on Jul 9, 2011 4:55 AM

    Edited by: nyambol on Jul 9, 2011 4:57 AM
  • 8. Re: Deploying Desktop Application
    bouye Journeyer
    Currently Being Moderated
    Indeed JavaFX 1.x applets & standalone app are not started directly by calling their main() function but must go through Sun/Oracle's launcher instead, so you need to keep this bit of code that NetBeans has generated for you.

    It's possible your program has an error that prevents the initial stage/frame from showing up.
    Open the Java control panel (or use javaws -viewer, and close/cancel the app list) and go to Advanced tab, extend the Java console node and check Show console. Click Ok to validate.
    This way the Java Web Start console will always show up whenever you try to launch your app so you may catch any exception that is thrown.

    If there is an error but it shows up on screen too fast (ie: the console closes as soon as the app crashes), try to enable logging and other debugging traces (it's in the Debugging node in the Advanced options) and then locate the JWS logs. The location may vary depending on your OS version, on my W7 box it's in C:\Users\<my home folder>\AppData\LocalLow\Sun\Java\Deployment\log I think. They are in XML and contain a backup of the exception that may have been thrown in the console. You may want to parse them and clear the XML noise to make them more readable to you.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points