2

I have defined javafx dependencies in pom.xml, but downloaded are .jars with manifest only and .jars for my specific OS - Windows (see picture).

Downloaded dependencies

<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-controls</artifactId>
    <version>15.0.1</version>
</dependency>
<dependency>
    <groupId>org.openjfx</groupId>
    <artifactId>javafx-graphics</artifactId>
    <version>15.0.1</version>
</dependency>

How to download others?

What i am trying to achieve?

I am trying to create 3 packages, each with my .jar application and javafx library for specific operating system, that is why i want to download javafx libraries for remaining OS (Linux, Mac).

Wortig
  • 963
  • 2
  • 11
  • 37

1 Answers1

1

You can use the <classifier> tag in your dependency
From the docs:

The classifier distinguishes artifacts that were built from the same POM but differ in content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.

My pom for cross-platform JavaFX-Applications usually look like this:

<dependencies>
    <!-- JavaFX - Windows -->
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-graphics</artifactId>
      <version>11</version>
      <classifier>win</classifier>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>11</version>
      <classifier>win</classifier>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-fxml</artifactId>
      <version>11</version>
      <classifier>win</classifier>
    </dependency>
    <!-- JavaFX - Linux -->
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-graphics</artifactId>
      <version>11</version>
      <classifier>linux</classifier>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>11</version>
      <classifier>linux</classifier>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-fxml</artifactId>
      <version>11</version>
      <classifier>linux</classifier>
    </dependency>
    <!-- JavaFX - Mac -->
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-graphics</artifactId>
      <version>11</version>
      <classifier>mac</classifier>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-controls</artifactId>
      <version>11</version>
      <classifier>mac</classifier>
    </dependency>
    <dependency>
      <groupId>org.openjfx</groupId>
      <artifactId>javafx-fxml</artifactId>
      <version>11</version>
      <classifier>mac</classifier>
    </dependency>

    <!-- other dependencies -->
</dependencies>
gkhaos
  • 694
  • 9
  • 20
  • What if i wanted to include only mac javafx on windows? When i include only block in pom.xml, win javafx is still downloaded. Same goes when i include linux block only. – Wortig Jun 16 '21 at 08:23
  • In short: yes, just remove the block you don't want to support. In long: I don't really understand your question. I think you assume because you found some library that it still ends up in your program. However, there is a whole lot more to actually run a java program on different platforms. The dependency in the pom-file is just about configuration. It basically tells maven to support these libraries. E.g. if you have packaging set to jar you can investigate that there is no library in the resulting jar at all... – gkhaos Jun 16 '21 at 09:17
  • @Wortig If you gather enough details I'm sure you can open a question to clear things up :) – gkhaos Jun 16 '21 at 09:19
  • I think too that you did not udnerstand it :) When I just remove the block i dont want to support it works for mac and linux, not for win. When i keep only mac for example, downloaded jars are for: mac and win. – Wortig Jun 16 '21 at 09:23
  • If you still do not know what i am asking i will open up a new Q. – Wortig Jun 16 '21 at 09:24
  • https://stackoverflow.com/questions/68000364/maven-include-javafx-dependencies-for-operation-system-i-am-currently-running-on – Wortig Jun 16 '21 at 09:52