# Possible bug in Modular Java Gradle run task

**URL:** <https://discuss.gradle.org/t/possible-bug-in-modular-java-gradle-run-task/40933>\
**Category:** Help/Discuss\
**Created:** [September 7, 2021, 4:30pm UTC](https://discuss.gradle.org/t/possible-bug-in-modular-java-gradle-run-task/40933 "2021-09-07T16:30:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cosmiczoo](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cosmiczoo](https://discuss.gradle.org/u/cosmiczoo)\
**Post date:** [September 7, 2021, 4:30pm UTC](https://discuss.gradle.org/t/possible-bug-in-modular-java-gradle-run-task/40933/1 "2021-09-07T16:30:30Z")

</div>

I have been checking out Gradle builds on Netbeans 12.4 for a small modular javafx application that runs both as a command line application and when run without arguments the application runs as a JavaFX application.

I think I have found a bug in the _ **run** _ task which is part of the Gradle Application plug-in. The problem does not show itself when I delete the **module-info.java** file, creating a classpath build…

The _ **run** _ task constructs a rather over-complicated looking command like that below. It appears to include the **bolded text** twice when building a modular application. As a consequence, the text that follows the bolded text is passed to the application as arguments that it does not recognise. If I run the command in a Netbeans Terminal without the bolded text the application starts without arguments and launches the JavaFX Application threads.

This behaviour applies to both Gradle 6.7 and Gradle 7.2. I am using Netbeans 12.4 on JDK-11 on Linux.

Is this a known or new bug?

Emma

Here’s the generated command:

/usr/java/jdk-11/bin/java --add-modules javafx.controls,javafx.fxml,javafx.graphics --module-path /home/emma/NetBeansProjects/CleanFilenameG/build/libs/CleanFilenameG-0.3.jar:/home/emma/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-core/2.14.1/9141212b8507ab50a45525b545b39d224614528b/log4j-core-2.14.1.jar:/home/emma/.gradle/caches/modules-2/files-2.1/org.apache.logging.log4j/log4j-api/2.14.1/cd8858fbbde69f46bce8db1152c18a43328aae78/log4j-api-2.14.1.jar:/home/emma/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-fxml/16/c7147c450773c3d4fd038ac9d1a6fdebbc3c11e0/javafx-fxml-16-linux.jar:/home/emma/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-controls/16/116b127e512d23ddb84c62017c256e7f67f5b9eb/javafx-controls-16-linux.jar:/home/emma/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-graphics/16/1bf2fd9f083daa2f492c4c58c4f7d5acb6f4b7d/javafx-graphics-16-linux.jar:/home/emma/.gradle/caches/modules-2/files-2.1/org.openjfx/javafx-base/16/7d6b85ec89e99ea40c2a63bb1f23d43e05cd2557/javafx-base-16-linux.jar --patch-module CleanFilenameG=/home/emma/NetBeansProjects/CleanFilenameG/build/resources/main **–module CleanFilenameG/cleanfilename.CleanFilename** -Dfile.encoding=UTF-8 -Duser.country=GB -Duser.language=en -Duser.variant --module CleanFilenameG/cleanfilename.CleanFilename

---

<div class="post-metadata">

**Author:** ![cosmiczoo](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cosmiczoo](https://discuss.gradle.org/u/cosmiczoo)\
**Post date:** [September 10, 2021, 8:28pm UTC](https://discuss.gradle.org/t/possible-bug-in-modular-java-gradle-run-task/40933/2 "2021-09-10T20:28:10Z")

</div>

Here’s a [JavaFX program on GitHub](https://github.com/cosmiczoo/gradle-problem-demo) that demo’s the problem

---

<div class="post-metadata">

**Author:** ![cosmiczoo](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@cosmiczoo](https://discuss.gradle.org/u/cosmiczoo)\
**Post date:** [September 16, 2021, 9:43pm UTC](https://discuss.gradle.org/t/possible-bug-in-modular-java-gradle-run-task/40933/3 "2021-09-16T21:43:29Z")

</div>

A fix has been developed.  
To use the fix put this in the plugins { } block before the javafx plugin of your build.gradle file.

> ```
> // Java Modularity plugin
> id 'org.javamodularity.moduleplugin' version '1.8.10'
> 
> // JavaFX Plugin
> // See https://github.com/openjfx/javafx-gradle-plugin
> id 'org.openjfx.javafxplugin' version '0.0.10'
> 
> ```

My GitHub demo now incorporates this fix. I’ll leave the demo up for a few weeks in case someone finds it useful.
