3

1-I created a jar package contains my module and also javafx modules inside itself how can i address --module-path to the javafx modules inside my jar package instead of external javafx library in JVM options to run my jar? image

2-I also used gradle with my project is there a way to create a jar contains javafx modules by build.gradle file without creating artifacts in project structure? image JDK 9 above and gradle 5 above

NotZack
  • 518
  • 2
  • 9
  • 22
phnix
  • 31
  • 2
  • Are you trying to merge your own module-info with the module-info for javafx classes that you added to your jar or are you trying to refer to the `javafx-swt.jar` entry in your jar file? – fabian Sep 01 '19 at 13:18
  • I wanna address javafx modules that are inside my jar to the JVM Options – phnix Sep 01 '19 at 13:23
  • You appear to have extracted the JavaFX classes (except for those in `javafx-swt.jar`) and placed them in your application's JAR file. For a non-modular application this should work, possibly requiring a few modifications. However, as I understand it there can only be one module per JAR file. As you can see in your image there's only one `module-info.class` remaining. This means you can't reference the JavaFX modules embedded in your JAR file because the JavaFX modules no longer exist; all the JavaFX code is now part of _your_ module. – Slaw Sep 01 '19 at 13:31
  • so how can i create a runnable jar without reffering to the external javafx library? i wanna create an executable jar which executes just by one click not specify external library by module-path in JVM options – phnix Sep 01 '19 at 13:35
  • You could make your application non-modular. The JavaFX modules can still be used from the classpath so long as your main-class is not a subclass of `Application`. [This answer](https://stackoverflow.com/a/54065502/6395627) goes into more detail. Unfortunately, there's no support for executable modular JAR files. The answer I linked to, however, does give options for a self-contained Java application which are compatible with modules. The should-be-coming-soon `jpackage` tool even allows for you to create native executables. – Slaw Sep 01 '19 at 13:53

0 Answers0