Home > Enterprise >  "/packages cannot be represented as URI"
"/packages cannot be represented as URI"

Time:08-21

I am working on a Scala project that use maven POM.xml file to build.

the build failed after adding test file that import "org.scalatest.FunSuite" or "...Matchers" with error message "/packages cannot be represented as URI"

plugin "scalatest-maven-plugin" is in used in the pom.xml but works file as long as there is no FunSuite or Matchers is imported

the test dependency in the pom looks like this

        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.12</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.scalatest</groupId>
            <artifactId>scalatest_${scala.binary.version}</artifactId>
            <version>3.0.5</version>
            <scope>test</scope>
        </dependency>

scala version: 2.12.7

maven version: 3.8.6

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_202.jdk/Contents/Home

CodePudding user response:

In My Case I had resolved this issue by installing a java version of 1.8 and set JAVA_HOME to this version.

export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_251.jdk/Contents/Home"

CodePudding user response:

Found the solution:

The Project Build of IntelliJ doesn't really care about the path of JDK in env var JAVA_HOME, it takes the one from project settings, so to solve this I have to:

  • go to File -> Project Structure (Command ;)
  • On the left select Project Settings, Modules
  • Select the module and from Module SDK drop list pick one of the compatible SDK like:
  • jdk1.8.0_202 or jdk1.8.0_251, correto1.8 or AdoptOpenJDK 1.8, ....
  • The ones that does NOT work with me are:
  • jbr17, correto16, temurin-17, ...

enter image description here

  • Related