'bad name in value for --add-modules when trying to compile through ant

I am trying to include the javafx.controls module in my project and compile it through ant, rather then use javaFX javac --module-path "..\lib\javafx-sdk-17.0.2\lib" --add-modules javafx.controls App.java

java --module-path "..\lib\javafx-sdk-17.0.2\lib" --add-modules javafx.controls App commands to compile the file(s).

This is how my ant build.xml looks like right now:

<project name="projectName" default="dist">
    <property file="build.properties"/>
    <property file="${user.home}/build.properties"/>

    <path id="run.classpath">
        <fileset dir="${dist.dir}">
            <include name="${project.name}.jar"/>
        </fileset>
    </path>

    <target name="compile">
        <mkdir dir="${build.dir}"/>
        <javac srcdir="${src.dir}"
               destdir="${build.dir}"
               debug="${compile.debug}"
               deprecation="${compile.deprecation}"
               optimize="${compile.optimize}"
               includeantruntime="false">
                <classpath>
                    <fileset dir="${lib.dir}/javafx-sdk-17.0.2/lib">
                        <include name="**/*.jar" />
                    </fileset>
                </classpath>
                <compilerarg line="--add-modules ${lib.dir}/javafx-sdk-17.0.2/lib/javafx.controls"/>
        </javac>
    </target>

    <target name="dist" depends="compile">
        <mkdir dir="${dist.dir}"/>
        <jar jarfile="${dist.dir}/${project.name}.jar"
             basedir="${build.dir}"
             manifest="${src.dir}/Manifest.mf">
             <zipgroupfileset dir="${lib.dir}/javafx-sdk-17.0.2/lib" includes="**/*.jar"/>
        </jar>
    </target>

    <target name="build" depends="dist">
        <java jar="${dist.dir}/${project.name}.jar" fork="true">
        </java>
    </target>

    <target name="clean">
        <delete dir="${build.dir}"/>
        <delete dir="${dist.dir}"/>
    </target>
</project>

The error I keep on getting is: error: bad name in value for --add-modules option: 'C:\xampp\htdocs\projectName/lib/javafx-sdk-17.0.2/lib/javafx.controls'. I have looked up the error, but the answers are very vague in my opinion and have not helped me get more knowledge in regards to the error.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source