Search code examples
javamaven

Java Maven can't find imports on local library in VSCode


I'm using the maven extension in VSCode on windows from microsoft and I'm trying to use a local jar library that I've used in the past in this project. This is a port from a non-maven project. the import statements fail with "The type {class} is not accessible." This is an old library and there is no maven repository and I am not the author. The library is included in the "dependencies" path of pom.xml, with the absolute file path name. (I tried the relative path but only got more warnings). I also tried putting it in the plugins section as suggested by other articles in stack overflow and other web sources. This made no difference, except made build errors. I have a similar issue with classes for which there is a maven repository. (javax, see below)

In VSCode, the "Java Projects" browser shows the files and the classes within, so the jar is intact and has the classes in it.

I tried setting up the dependencies in pom.xml:

        <!-- https://mvnrepository.com/artifact/javax.vecmath/vecmath -->
        <dependency>
            <groupId>javax.vecmath</groupId>
            <artifactId>vecmath</artifactId>
            <version>1.5.2</version>
        </dependency>
        <dependency>
            <groupId>toxi</groupId>
            <artifactId>geom</artifactId>
            <version>0021</version>
            <scope>system</scope>
            <systemPath>d:\Thomas\toxiclibs\toxiclibscore.jar</systemPath>
        </dependency>

I tried to install the local library with mvn. I also tried putting it in a plugin in pom.xml, but that made no difference except to complain there wasn't a phase, when it built. I tried using this page: https://maven.apache.org/guides/mini/guide-3rd-party-jars-local.html

I expect that the libraries should be found on the import statement. They are still giving "The type {class} is not accessible." (forgive the duplicate info) Thank you.


Solution

  • This appears to have been caused by my module-info.java file. it kept showing errors and I tried to fix them. ultimately I deleted it and the project works. I do not need modules in this small project.