Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12141

Create a runnable JAR manually by creating a zip file

$
0
0

I'm trying to create a runnable JavaFX JAR.

I have compiled all files (using Java 8, major version 52), creates a Manifest file and created a zip that contains these directories and files:

app.zip

META-INF  MANIFEST.MFlib  javafx-controls.jar  ...animals  Dog.class  Cat.classshapes  Circle.class  Square.classcontrollers  AllAnimalsController.classviews  allanimals.fxmlMain.class

Then I renamed the zip into app.jar.

The lib folder contains all JavaFX dependencies. I can run the jar by doing this:

java --module-path lib  --add-modules javafx.controls,javafx.fxml   -jar app.jar 

But only if I run the jar from a directory that contains a lib folder:

running-jar-test-directory  app.jar  lib    javafx-controls.jar    ...

I can't make the jar run using its own lib folder (one packaged inside the jar), without relying on external lib folder located in running-jar-test-directory.

How do I accomplish it?

I tried updating my MANIFEST.MF to include all jar files in the lib folder like this:

Manifest-Version: 1.0Class-Path: lib/javafx-controls.jar ...Main-Class: Main

But it didn't work - I get errors when trying to run the jar:

java   --add-modules javafx.controls,javafx.fxml   -jar app.jar Error occurred during initialization of boot layerjava.lang.module.FindException: Module javafx.controls not found
java  -jar app.jar Error: Could not find or load main class MainCaused by: java.lang.NoClassDefFoundError: javafx/application/Application

I know there are tools/plugins for creating the JavaFX jars, but I want to understand how to do it manually.


Viewing all articles
Browse latest Browse all 12141

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>