Search code examples
javamavenintellij-ideapom.xmlnd4j

why can't Maven find the nd4j .jar file after adding the dependency to pom.xml?


I created a maven program in intellij-idea with openjdk-20, and I put the dependency for nd4j in the dependencies section in pom.xml, and imported nd4j.*, but when I ran the program, it raised this error:

Could not find artifact org.nd4j:nd4j:jar:1.0.0-M2.1 in central (https://repo.maven.apache.org/maven2)

I tried "running the Maven import with -U", which was what the compiler said would fix the error, but it still raised the same error. I also went to the repo.maven.apache.org website, and it didn't have nd4j there.


Solution

  • I think you are trying to include nd4j dependencies the wrong way. If I am reading the instructions correctly, you are supposed to add the Deeplearning4j dependency:

    <dependencies>
      <dependency>
          <groupId>org.deeplearning4j</groupId>
          <artifactId>deeplearning4j-core</artifactId>
          <version>1.0.0-M2.1</version>
      </dependency>
    </dependencies>
    

    and a dependency for one of the nd4j backend modules; e.g.

    <dependencies>
      <dependency>
          <groupId>org.nd4j</groupId>
          <artifactId>nd4j-native-platform</artifactId>
          <version>1.0.0-M2.1</version>
      </dependency>
    </dependencies>
    

    You have apparently used something like this instead:

    <dependencies>
      <dependency>
          <groupId>org.nd4j</groupId>
          <artifactId>nd4j</artifactId>
          <version>1.0.0-M2.1</version>
      </dependency>
    </dependencies>
    

    That doesn't work because that dependency denotes a parent POM not a JAR file.


    I also went to the repo.maven.apache.org website, and it didn't have nd4j there.

    It was there when I looked. But as I said, it is a POM file not a JAR file.