Hello all,
I'm pretty sure this is a silly question but this is driving me crazy as I don't know what to do to work it out. I am not a Java expert although I have some programming skills. I'm trying to use Visual Code + Java Extension Pack as I thought it could be a good combination.
I am not using any project (eclipse, maven, etc) as I'm only creating short and straightforward programs. The problem I'm facing is when I try to use some classes from a jar file (for instance, algs4.jar from https://algs4.cs.princeton.edu/code/algs4.jar)
I create a simple java file in a directory that uses some of the classes with an import directive and I've added the directory where algs4.jar resides to my classpath (operating system) variable. From the command line, I can run successfully javac and java command, so everything looks fine (no errors, no warning, etc). I can compile and run my program. But when I try to run my java file from Visual Code, I receive the following error:
The import edu cannot be resolved
The import edu cannot be resolved
StdRandom cannot be resolved
StdRandom cannot be resolved
StdStats cannot be resolved
StdStats cannot be resolved
at PercolationStats.<init>(PercolationStats.java:7)
at PercolationStats.main(PercolationStats.java:105)
It clearly shows that Visual Code can't find the jar file but I don't know what to do to teach VC where that file resides.
Would kindly someone help me to work this problem out? By the way, where can I find more information about the usage of VC + Java?
Thank you very much.
These are my import lines
import edu.princeton.cs.algs4.StdRandom;
import edu.princeton.cs.algs4.StdStats;
The Eclipse backend providing java support in vscode-java doesn't have access to customized libraries added to the JDK.
We strongly encourage our users to depend on a build tool such as Maven or Gradle to define the project classpath, as we have no intentions of defining yet another kind of classpath declaration mechanism.
Here's a Maven-based project to help you started. The pom.xml, or project descriptor, is pretty self-explanatory (and a bit verbose). You'll find:
https://github.com/eclipse/eclipse.jdt.ls/pull/927 should help, by just adding jar files in a lib/ folder at the root of the directory.
See

Woo! Unbelievable!
@fbricon thanks!
Most helpful comment
https://github.com/eclipse/eclipse.jdt.ls/pull/927 should help, by just adding jar files in a lib/ folder at the root of the directory.
See
