Export JavaFX 11 Project into executable jar(2020)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so until now while writing our program we will always run it by pressing the green button in our IDE and then run it of course this is never the case in real life in real life when we want to open a program which usually we go to its path and double-click and let's do this in our lecture let's export an executable jar from our program so I will go in my IntelliJ this lecture I will use IntelliJ for Eclipse it might be different I'll go to file project structure select go to artifacts and create the plot and click the plus sign and I can use the Java FX application option there's a catch here I will just say a Java FX test I will call it JavaFX test I will select our available items all of them and say back into Java FX email client jar it will be and in our Java FX path I need to specify the application class so I'll say comm I'll click apply click OK and go to build build artifacts and build and I will get some interesting error right here it will say can't build artifact FX deploy is not available in this JDK so horror call has even make made deployment of Java FX projects even more complicated so this is not a solution so I will undo what I did now I will delete this file it's just an XML and if so currently the jar exists so I can go to my idea projects and go to the out directory and in the artifacts I have this folder and I have this jar but it is invalid I can open it but it is invalid so I will take another approach let me delete this I once again go to file project structure artifacts click the plus sign but this time I will select jar and from module with dependencies I will select our project and select our main class which is our launcher this time you can see that it already runs better since it directly knows my main class click OK and click OK I will click apply and ok and again run I mean build and build artifacts and the same artifact I will build it it's built and it's here and there's another catch if here if I want to run it if you are familiar with with Java I can usually say first of all to run this Java FX jar you need at least Java version 11 so I can say Java - version in my terminal here and you must have at least Java 11 to run this jar and usually when running a jar all we need to do is say Java - jar and our jar and of course this is not the case anymore because things are getting very complicated with Java FX it says Java FX runtime components are missing and are required to run this application I looked many hours on the web for solution and finally on the site of Joe open GFX I found a soul let me open it and here they say that I need to export the path to our Java FX executable and I also when running our program I need to specify the modules which I require for my application let's do this and for this I will create a text file here in which we will build our command so I will just say a plain text create and let's edit this so how will our command look like first of all we need Java Java then module path and here I need the path to my Java FX installation so I will go to where my installed Java FX in my case it's in my work it's in Java lips Java FX and run and copy this path here back to our file this is our path to Java FX and then I need to add every module that I use in my class so I'll paste this code after that we can say - jar and then we can specify our jar this is how our big command just to run a simple project looks like so I will open again one more time in I already have a terminal here and this time if I paste this this command here with specifying the path to Java FX and with the modules it should work hopefully okay there's a small mistake with my with my code I will copy it again I have it I had a typo and if I paste again my command in my terminal this time I'm able to run and open my project outside my IDE this is great I can press it and I can see the main view that's great and of course we don't want to always write a long come and just to open our project and for this I will create a new SH file so I can call it run dot as age it is an executable Linux file you need a bat script for Windows and I will edit it and paste our command here save it edit it in order to have access to run programs and then again I will open a terminal here and this time all I need to do to run our program is just dot slash and run dot as age and this way I'm a I'm able to run our program nicely outside our ID
Info
Channel: Alex Horea
Views: 43,551
Rating: undefined out of 5
Keywords: Jar, JavaFx, Java, executable, JavaFx11
Id: HGHu-SzL-5E
Channel Id: undefined
Length: 7min 32sec (452 seconds)
Published: Mon Sep 09 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.