title: VSC wrong java dependencies
body: <p>I have a strange behaviour in Visual Studio Code, trying to debug a simple code with the VSC Debugger I have a runtime error, running the same code with Gradle the code works !</p>
  <p>The problem is that running the code in VSC Debug mode the java code try to load two library, the <code>commons-cli-1.2.jar</code> and the new <code>commons-cli-1.5.0.jar</code>, in the old one some methods are not implemented and the code rise a <code>java.lang.NoSuchMethodError</code></p>
  <pre><code>[144.386s][info][class,load] java.lang.Throwable$WrappedPrintStream source: jrt:/java.base
  java.lang.NoSuchMethodError: 'boolean org.apache.commons.cli.Options.hasShortOption(java.lang.String)'
      at org.apache.commons.cli.DefaultParser.handleShortAndLongOption(DefaultParser.java:473)
      at org.apache.commons.cli.DefaultParser.handleToken(DefaultParser.java:542)
      at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:712)
      at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:679)
      at org.apache.commons.cli.DefaultParser.parse(DefaultParser.java:660)
      at it.fox.dafne.App.main(App.java:38)
  </code></pre>
  <p>The java code is:</p>
  <pre class="lang-java prettyprint-override"><code>  public static void main(String[] args) throws Exception {
      Options options = new Options();
      options.addOption(&quot;f&quot;, PROPERTY_FILE, true, &quot;path to the properties file&quot;);
      try {
        var parser = new DefaultParser();
        CommandLine commandLine = parser.parse(options, args);
        String propertyFile = &quot;&quot;;
        ...
        ...
  </code></pre>
  <p>In the ClassPath there's no indication of the old library:</p>
  <pre class="lang-xml prettyprint-override"><code>   &lt;classpathentry  sourcepath=&quot;/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.5.0/e7e198ff537780c2835e484b0ffccd2960074504/commons-cli-1.5.0-sources.jar&quot; kind=&quot;lib&quot;  path=&quot;/Users/fox/.gradle/caches/modules-2/files-2.1/commons-   cli/commons-cli/1.5.0/dc98be5d5390230684a092589d70ea76a147925c/commons-cli-1.5.0.jar&quot;&gt;
  </code></pre>
  <p>So, how is it possible for Java to find the Old version?</p>
  <p>Visual Studio Code isn't supposed to use the java classPath which is in <code>.classpath</code> file ?</p>
  <p>Enabling <code>-verbose:class</code> when the JVM is launched, the error is pretty clear:</p>
  <pre><code>[7.861s][info][class,load] org.apache.commons.cli.Options source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  [7.862s][info][class,load] org.apache.commons.cli.Option source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  [7.864s][info][class,load] org.apache.commons.cli.OptionValidator source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  [7.867s][info][class,load] org.apache.commons.cli.CommandLineParser source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  [7.867s][info][class,load] org.apache.commons.cli.DefaultParser source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.5.0/dc98be5d5390230684a092589d70ea76a147925c/commons-cli-1.5.0.jar
  [7.868s][info][class,load] org.apache.commons.cli.ParseException source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  [7.868s][info][class,load] org.apache.commons.cli.MissingArgumentException source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  [7.869s][info][class,load] org.apache.commons.cli.MissingOptionException source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  [7.870s][info][class,load] org.apache.commons.cli.UnrecognizedOptionException source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  [7.870s][info][class,load] org.apache.commons.cli.AmbiguousOptionException source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.5.0/dc98be5d5390230684a092589d70ea76a147925c/commons-cli-1.5.0.jar
  [7.871s][info][class,load] org.apache.commons.cli.CommandLine source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  [7.872s][info][class,load] org.apache.commons.cli.Util source:  file:/Users/fox/.gradle/caches/modules-2/files-2.1/commons-cli/commons-cli/1.2/2bf96b7aa8b611c177d329452af1dc933e14501c/commons-cli-1.2.jar
  </code></pre>
  <p>In Gradle the dependencies are fine:</p>
  <pre><code>MacBook-Pro:plcProject fox$ gradle dafne:dependencies | grep commons-cli
  |  |  |  |  |  +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  |  |  |  |  +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  |  |  |     +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  +--- commons-cli:commons-cli:1.5.0
  +--- commons-cli:commons-cli:1.5.0 (n)
  +--- commons-cli:commons-cli:1.5.0 (n)
  |  +--- commons-cli:commons-cli:1.5.0
  |  |  |  |  |  |  +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  |  |  |  |  |  +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  |  |  |  |     +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  +--- commons-cli:commons-cli:1.5.0
  |  |  |  |  |  +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  |  |  |  |  +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  |  |  |     +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  +--- commons-cli:commons-cli:1.5.0
  |  +--- commons-cli:commons-cli:1.5.0
  |  |  |  |  |  |  +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  |  |  |  |  |  +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  |  |  |  |     +--- commons-cli:commons-cli:1.2 -&gt; 1.5.0
  +--- commons-cli:commons-cli:1.5.0
  </code></pre>
  <p>Gradle find some transitive dependencies but decide to use the newer version of the library and not the old one:</p>
  <p>So the questions are:</p>
  <ul>
  <li><p>VSC ClassPath is the Gradle one?</p>
  </li>
  <li><p>How could be possible that launching the code with Gradle is working and with VSC not ?</p>
  </li>
  </ul>
  <p>Thanks,</p>
  <p>S.</p>