Create executable jar file for JavaFX 11+ using Maven [2021]

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey it's upfront student here and today i'm going to showcase how to create an executable java file using maven so i already have a javascript application running which uses maven of course and i will have a link up here demonstrating how to get to this point how to create a javafx application using waven let's just demonstrate the program i have for now where i just have a very simple program where i can switch between a primary and a secondary view so the first thing we need to do is we need to create a new class which starts the program because at the moment my public class app which starts the program is extending something else and the jar files don't like having to run a class that's extending something else first i will just create a new java class and i'm just going to call it main inside main i'm just simply going to create a public static void main method where i will just very simply call my app dot main and then get all the arcs so just gonna call all information inside my main inside up class so now when i run main the program just starts as normal then what is the main part of this is inside my poem.xml file i have this plugin which is going to create a maven shade jar class which is what we call a fat jar which means it don't only use the the files of the program but also include the libraries which is what we need because in the newer versions of javafx and java java don't include these libraries to begin with we need to add them manually so of course i'm going to add this entire poem.xml a maven file in the description but mainly it is this plugin which is doing all the works where i just simply have that id i have the artifact the shape plugin and then very important we need to change the main class to be the main class you want to run so in my case this is the org.example.com main and i'm then first gonna hover it right here or you can double click on control we can get i run anything page where i would first run an nbn so i'm even clean which is very simple cleans the file and remove all the target files i would then run my main just to make sure my program works let's create a new target file i will then again control control mvn install which is going to create inside my target folder a jaw file it finished and it might give some problems but it should probably work anyway sometimes the first time you run my given problem so i have a normal jar file which i can't just run and i have my shaded jar file which i will be able to run so now i'm just going to right click and open it inside explorer where i have my normal jar file which does nothing but when i double click on my shaded file i am able to have this running and i am now able to take this jar file and move it or do whatever i want to do with it and it will then be able to run my program so this is pretty much the setup make sure you have a class that calls your class that extends application with javafx and then just very simply make sure you perm.xml maven file includes this plugin and have your main class set to the main class you want to run so if you enjoyed this video please leave a like and subscribe and i wish you all a wonderful day
Info
Channel: Random code
Views: 3,222
Rating: undefined out of 5
Keywords: javafx, maven, javafx tutorial, create jar file, javafx 11 maven, javafx maven project, jar file, executable javafx jar, how to create maven javafx project, maven jar file creation, export jar file, jar, how to create jar file, export jar file of javafx project, how to export javafx project in jar file, javafx maven, how to create a jar file with maven, maven java, javafx jar, java, scene builder, executable jar, executable jar file, export jar, javafx 15 exeutable jar
Id: EyYb0GmtEX4
Channel Id: undefined
Length: 3min 58sec (238 seconds)
Published: Sun May 02 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.