JavaFX 2 Tutorial Part VII - Deployment With e (FX) Clipse - Edu - Makery PDF
JavaFX 2 Tutorial Part VII - Deployment With e (FX) Clipse - Edu - Makery PDF
edu.makery.ch
How to Make Things.
Search
Navigate
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/
1/13
18/07/13
I thought Id write one last part of this tutorial series to show how to deploy (i.e. package and publish) the AddressApp. Download example AddressApp as Windows exe installer: AddressApp-0.7.exe. MacOS dmg drag-and-drop installer: AddressApp.dmg - Thank you Eskil for providing this!
What is Deployment
Deplyoment is the process of packaging and delivering software to the user. This is a crucial part of software development since its the first contact a user has with our software. Java advertises with the slogan Write Once, Run Anywhere to illustrate the cross-platform benefits of the Java language. Ideally, this means that our Java application can be run on any device equipped with a Java virtual machine (JVM). In the past, the user experience for installing a Java application hasnt always been smooth. If the user didnt have the required Java version on his system, he had to be directed to install it first. This lead to some difficulties, e.g. need for admin rights, compatibility issues between Java versions, etc. Fortunately, JavaFX 2 provides a new deployment option called Native Packaging (also called SelfContained Application Package). A native package is a bundle containing both your application code and the (platform-specific) Java Runtime. The official JavaFX documentation by Oracle contains an extensive guide for all possible JavaFX deployment options. In this post I will show how to create a Native Package with with Eclipse and the e(fx)clipse plugin. My current e(fx)clipse version is 0.1.1.
18/07/13
The a p pfolder contains our application data and the r u n t i m efolder contains the platform-specific Java runtime. To make it even more comfortable for the user, well provide an installer: A. e x efile installer on windows Ad m g(drag and drop) installer for MacOS. The e(fx)clipse plugin will help us generate the native package and installer.
Step 1 - eclipse.ini
Note: Step 1 might not be necessary with e(fx)clipse 0.8.0 and above. See Tom Schindls comment below (the author of e(fx)clipse). JavaFX uses a tool called Ant to build and package the application. This tool is already included in Eclipse. As Ant depends on the JDK we need to make shure Eclipse itself runs with the JDK (not the JRE). 1. Close Eclipse. 2. Find the folder of your Eclipse installation and open the file e c l i p s e . i n iin a text editor. This file contains Eclipse startup settings. On Mac OS X, eclipse.ini can be found by right-clicking Eclipse.app and selecting Show package contents. The file is located under Contents/MacOS. 3. After the line o p e n F i l eadd v mand then specify your jdk installation directory. The end of the file should now look like this: eclipse.ini
1o p e n F i l e 2v m 3C : \ P r o g r a mF i l e s \ J a v a \ j d k 1 . 7 . 0 _ 0 9 \ b i n \ j a v a w . e x e 4v m a r g s 5X m s 4 0 m 6X m x 5 1 2 m
Mac OS: For Mac OS, path can be something like /Library/Java/JavaVirtualMachines/jdk1.7.0_07.jdk/Contents/Home/bin/java (In my version the javaw.exe does not exist but I specified java instead which seemed no problem)
18/07/13
1. Download AddressApp.ico, AddressApp-setup-icon.bmp and AddressApp.icns. 2. Copy the three icons to the project root of your AddressApp project in Eclipse.
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/
4/13
18/07/13
3. As Packaging Format choose e x efor Windows, d m gfor MacOS, and r p mfor Linux. 4. Click on the link G e n e r a t ea n tb u i l d . x m lo n l y(found on the right side). 5. Verify that a new b u i l dfolder and a file b u i l d . x m lis created.
18/07/13
2 < f i l e l i s t > 3 < f i l en a m e = " $ { j a v a . h o m e } \ . . \ l i b \ a n t j a v a f x . j a r " / > 4 < f i l en a m e = " $ { j a v a . h o m e } \ l i b \ j f x r t . j a r " / > 5 < f i l en a m e = " $ { b a s e d i r } " / > 6 < / f i l e l i s t > 7< / p a t h >
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/
6/13
18/07/13
With Inno Setup we can create a Windows Installer of our application as a single . e x efile. The resulting . e x ewill perform a user level installation (no admin permissions required). A shortcut will be created (menu or desktop) 1. Download Inno Setup 5 or later. Install Inno Setup on your computer. Our Ant script will use it to automatically generate the installer. 2. Tell Windows about the installation path to Inno Setup (e.g. C : \ P r o g r a mF i l e s( x 8 6 ) \ I n n o S e t u p5 ): Add it to the P a t hvariable in your windows environment variables. If you dont know where to find it, read How to set the path and environment variables in Windows.
To create a Mac OS d m gdrag-and-drop installer, no additional tool is required. Note: For the installer image to work it must have exactly the same name as the application.
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/
7/13
18/07/13
The building will take a while (about 1 minute on my computer). If everything was successful, you should find the native bundle in the folder b u i l d / d e p l o y / b u n d l e s : Windows: The file A d d r e s s A p p 1 . 0 . e x ecan be used as a single file to install the application. This installer will copy the bundle to C : / U s e r s / [ y o u r n a m e ] / A p p D a t a / L o c a l / A d d r e s s A p p . Hint: You could also use the subfolder b u i l d / d e p l o y / b u n d l e s / A d d r e s s A p pto deploy the application as a . z i pfile.
Whats Next?
I hope this tutorial was a help for you to get started with JavaFX and youll be able to write your own JavaFX project from here. I might add some further JavaFX blog posts outside of this tutorial series, well see I appreciate any feedback. Feel free to write comments if you have any suggestions or if something was unclear.
Download Source
Source of Tutorial Part VII as Eclipse Project. Posted by Marco Jakob Updated May 22nd, 2013 English, JavaFX
Tweet 4 0
Comments
31 comments Leave a message...
Best Community Albert55
Share
3 months ago
Please I need your help. I am using a H2 embedded database in my javaFX application. the database file is in my src folder in a java project under eclipse . How can I deploy it with my application. I used the method you described it but It didn't work. Thanks
5
Reply
Share
a month ago
hello marco,
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/ 8/13
18/07/13
Your tutorial is realy good but i have a little problem. It didn't work as you explained. I had to add a classpath in my build xml. <property location="C:\Program Files\Java\jdk1.7.0_10\jre\lib\jfxrt.jar" name="classpath"> because he didn't found the jfxrt.jar. Now your adressapp makes a native bundle as discribed. When i install it on my pc i get an error jvm.dll not found. Is this problem caused by my adation? Now i would like to know which jvm he doesn't find. I have a jvm.dll in 5 different jdk directories en 3 jvm.dll in my jre directories.</property>
Reply Share
Mod
Marco Jakob
a month ago
I think it should probably find your jdk without the change you made. So try removing your property location and make sure that ant finds your jdk.
1
Reply
a month ago
rohini
Finally I found the solution for my problem. Because I am a newbie I didn't know that in eclipse I had to adapt the External Tools configurations. (Eclipse Run External Tool External Tool Configurator ) Under the tab JRE You can change this. There i added a seperate JRE as standard machine that points to my last JDK. Perhaps this is some information who may be usefull for other newbies.
Reply Share
a month ago
i have created build.xml. however its not taking external dependency jars for my project. How can i add those. Thanks in advance!
Reply Share
a month ago
Very nice tutorial Marco, it help me a lot!!!! but it would be very nice if you update it with some kind of REST backend communication and not XML like Spring, roo, grails or something like that to persist the data to a database. Sorry if my english is bad :(. Thanks in advance.
Reply
Share
craigTheBrit
2 months ago
I'm opening some assets in my application using [class].getResourceAsStream([absolute path to asset]). This works fine when the app runs from fxclipse, but the method always returns null when being run in the jar, and hence the app fails to open. There's something in the back of my mind about having to add directory path listings to the JAR file (maybe manifest?) but I can't think how to do this in the ant task's build.xml. Any ideas?
Reply Share
9/13
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/
18/07/13
Marco Jakob
Mod
> craigTheBrit
Share
2 months ago
craigTheBrit
2 months ago
Rossco
Yes - stackoverflow comes to the rescue again! The solution for me was to use getClassLoader().getResourceAsStream(...) and provide the full path to the asset in the form "com/...", with no preceding slash. Thanks for the tutorial!
Reply Share
2 months ago
after following all the steps, when I try to run the AddressApp.exe that's generated I get: "The version of this file is not compatible with the version of Windows you're running. Check your computer's system information to whether you need an x86 (32-bit) or x64 (64-bit) version of the program, and then contact the software publisher." I even did step 1, specifying the path to the jdk in the eclipse.ini file
Marco Jakob
> Rossco
Share
2 months ago
Make sure you have all ingredients in either 32bit or 64bit. That means if you want a 32bit version you should have a 32bit JDK (specified in eclipse.ini) and a 32bit Eclipse.
Reply Rossco
2 months ago
everything checks out: 32bit JDK with 32bit eclipse on 32bit Windows 7 Like "Carlos Henrique Latanza" I'm also using a later version of e(fx)clipse than you are, which does not have a "native package" option (version: 0.8.1.2); perhaps this is why I've experienced issues. What version of e(fx)clipse are you using? I'll try to go with that and see if it makes a difference.
Reply Share
Mod
Marco Jakob
> Rossco
2 months ago
rossco
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/
I've updated the blog post for e(fx)clipse version 0.8.1. There is no 'native pack option' any more but instead you need to choose the 'Packaging Format'.
Reply Share
> Rossco
2 months ago
10/13
18/07/13
rossco
JavaFX 2 Tutorial Part VII - Deployment with e(fx)clipse - edu.makery.ch Rossco 2 months ago
>
rossco
Share
Marco Jakob
> rossco
Share
2 months ago
yep, 0.1.1 is the last version I tried. Let's see if I can reproduce your issue.
Reply
> rossco
2 months ago
also: just noticed that nothing is being generated in the "dist/resources" folder.
Rossco
> rossco
2 months ago
"you need to choose the 'Packaging Format'." yeah, that was it. all problems solved. works 100% would be awesome if the user could be able to select default app location download upon installation (ex. C:\Program Files, C:\Desktop, etc.), but this is a very nice start.
Carlos Henrique Latanza
thanks for the wicked awesome tutorials, and for the incredible help!
Reply
Mod
Share
Marco Jakob
> Rossco
Share
2 months ago
Rossco
> Rossco
Reply
2 months ago
I mean: if the user could be able to select default app download location* upon installation
Share
2 months ago
im stuck at step 3,i dont have the native pack option on deploy tab, can you help me please?
Reply Share
Mod
Marco Jakob
2 months ago
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/
I've updated the blog post for e(fx)clipse version 0.8.1. There is no 'native pack option' any more but instead you need to choose the 'Packaging Format'.
Reply
11/13
18/07/13
Pavel Degtev
Reply
Share
Marco Jakob
Mod
2 months ago
Maybe there is a new version of e(fx)clipse where things are a little different. I don't have a new version installed right now.
Reply
4 months ago
Buttons apear clipped Ne.... Ed..... Ca..... if run exe or from instal. But looked correct if run from eclipse. What wrong ?
Reply
Share
4 months ago
Pavel Degtev
Spasibo! Ochen tolkovoe, poleznoe,celnoe rukovodstvo. Thank you, very good, usefull, "fullended"( : ) ) tutorial.
If any other on JavaFX - you will find time and effort for - will be very good. ; )
Reply
Share
whatOne
CO
Reply
6 months ago
Share
Thank you!
Tom Schindl
7 months ago
With the upcoming release 0.2.0 the preconfiguration of the JDK is not needed anymore. If the ant launch generator detects that it runs only with a JRE it wil pop up a dialog asking for a JDK.
Support for deployment customization as shown is scheduled for the next release after 0.2.0
Reply Share
Mod
Marco Jakob
7 months ago
Wow, great! These are exactly the two important things that are missing. Looking forward to the next release!
Ralph
7 months ago
I'm on linux (debian-like). The build only work after i change the location of ant-javafx.jar and jfxrt.jar to absolute path. For some reason it did not found the location of "java.home". After the build was complete, the .deb and .rpm packages was created. I tried to run it through "AddressApp" under the "build" dir, but got the error "jvm.dll is not found [...]
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/ 12/13
18/07/13
Marco Jakob
> Ralph
Share
7 months ago
I've had the exact same error with Windows before. Starting Eclipse with -vm C:\Program Files\Java\jdk1.7.0_09\bin\javaw.exe solved it for me (see Step 1 above).
Reply Ralph
7 months ago
Projects
Find it another way to successfully compile: add ant-javafx.jar and jfxrt.jar at the global entries classpath on Ant runtime configuration at eclipse. However, the "jvm.dll is not found" still persist when the application is executed. Strange is, the build process copy libs to deploy location instead of using existing libraries at the O.S. Is this normal?
Reply Share
Learn Programming Learn JavaFX Dart HTML5 Drag and Drop Dart Event Bus
Categories
All (24) Dart (1) Deutsch (1) English (23) Java (6) JavaFX (16) Copyright 2013 - Marco Jakob - Powered by Octopress - Icons by glyphicons and icondrawer
edu.makery.ch/blog/2012/12/18/javafx-tutorial-addressapp-7/
13/13