Build, deploy and run!
Pjuh, you made it here? Okay, right-click the SomeApp-ear project and select Clean and Build.
If you want Java Web Start to work, you cannot deploy the application through NetBeans (yes it must be a bug). Instead, make sure your GlassFish server is started (Tab Services > Tree node Servers > Right-click and select Start). Open a browser and go to the admin console at http://localhost:4848. Click on the Applications tree node to your left. Click button Deploy… > Choose File. Then select the newly built SomeApp-ear.ear file. On my machine, I found it here:
Make sure Java Web Start is ticked and then hit OK. If you look in your GlassFish console (back in NetBeans), you’ll notice that GlassFish complains about not being able to find two classes:
Don’t worry too much about it. If we had packaged our JavaFX runtime library with our application client, GlassFish wouldn’t make this noise. However as you soon will see, the complaints has to the best of my knowledge no bearing.
In the list of deployed applications, click SomeApp-ear. In the Modules and Components table, click the Launch link. That should take you to a page with two URL:s. Copy-paste the URL of the first one into the browser’s address bar. If your GlassFish server works like mine, you have to change a phony computer name into localhost instead before you try to follow the link. Once you do follow the link, your browser downloads a JNLP file that you can double-click to execute your application client. First run might take some time!
When you’re prompted for username and password, enter user and password:
Did you notice that the login screen is made with Swing components? Click OK and you shall be thrown into a nice hardware accelerated JavaFX application. Click on the Click Me! button and if everything works, you should see the text “Remoting is awesum.” just beneath the button:
If your application client failed to launch with a deceptive exception thrown..
..then there is a fix for that too. Undeploy your application. Stop GlassFish. Delete your GlassFish disc caches. On my machine, I delete all I can find in these two folders (your domain might be called “domain1” instead of “gfdomain”):
Happy JavaFX coding! And don’t forget to share your thoughts and whatever else you might find related to this tutorial.