Task: You need to make an executable JAR file with a JavaFX game using the graphics engine from CodeGym.

For this you will need to :

  1. Fork from the repository https://github.com/CodeGymCC/project-maven.git
  2. Download your version of the project to your computer. Next, we will work with the pom.xml file, located in the root project folder.
  3. Add dependencies:
    • org.apache.commons:commons-lang3:3.12.0
    • org.openjfx:javafx-controls:18.0.1
    • com.codegym: desktop-game-engine:1.0 (this dependency will be covered in the next section)
    • org.junit.jupiter: junit-jupiter-engine: 5.8.2 (with 'test' scope)
  4. In the plugins section:
    • leave the maven-compiler-plugin unchanged
    • install the com.codegym: desktop-game-engine:1.0 dependency from the lib library to the local repository (google for help)
    • add the maven-surefire-plugin, and make a configuration so that the StrangeTest test class does not run on build. The rest of the tests should run.
    • add the maven-jar-plugin, which will make a jar file containing the game code and dependencies. In this plugin, you need to configure the MANIFEST.MF file to contain sections: Class-Path, Main-Classand Rsrc-Main-Class
    • all our JAR dependencies should be registered in Class-Path.
    • for Main-Class, the org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader class must be used, which can use the classpath from JAR files, and can also start a JavaFX application
    • for Rsrc-Main-Class, the starting class of the game (com.codegym.games.racer.RacerGame) must be used
    • add a plugin that will collect all dependencies (with 'compile' scope) and add them to some directory during the build
  5. Add a “resources” section to say that the built JAR dependencies are a resource, so that the maven-jar-plugin puts them inside the JAR file into the new lib/ folder
  6. Upload changes to your GitHub repository, and send a link to it to your teacher.


  1. The build must be run with the mvn clean install command.
  2. Running the game (via Maven) for the purpose of viewing can be done with the mvn javafx:run command.
  3. The phase for some of the plugins needs to be overridden.
  4. The project uses JDK version 18.0.1. This JDK version, or higher, must be installed on your computer.
  5. When building through Maven, there will be errors at first. Read them carefully and you will simplify your life.
  6. Do not change anything in the org.eclipse.jdt.internal.jarinjarloader package. It has a custom loader class (honestly copied from StackOverflow), in which the launch of the main method is changed to launch the JavaFX application. Use for educational purposes only.
  7. If you complete all the points, as a result of the assembly you will receive a fat-JAR file. You can start and check that everything is done correctly with the command:
    <way to java 18> -jar <the name of the resultant jar file>
    "C:\Users\leo12\.jdks\openjdk-\bin\java.exe" -jar "E:\temp\project-maven-1.0.jar"
  8. As a result you will see:
  9. The build depends on your operating system. That is, if a JAR file is built on Windows, it can be run on any Windows computer with Java 18+, and therefore will not run on Mac and Linux.

Project analysis. Watch after completion!