Scala import java package appending com
java, scala
Solution
Use `_root_` prefix in import statements. It makes package resolution absolute.
import _root_.company.product.core.ClassName
import _root_.com.company.product.other.ClassName
Referring to you comment: with relative imports you could do something like this. It basically saves you some typing.
import _root_.company.product.core
import ClassAFromCore
import ClassBFromCore
Problem
I'm working on a Scala project that is importing two java libraries. Through poor planning, the two java libraries have similar package names, one with com on the front, one without. The problem is that Scala is looking for the package with com in front first, and telling me that the package doesn't exist. If I remove all references to the library with com in front of the package, the compile works. To show an example that makes sense: In foo.jar we have a package company.product.core In bar.jar we have a package com.company.product.other. If both jars are on the classpath, the line: ``` import company.product.core.ClassName ``` Fails with the error "value core is not a member of package com.companyname.product" If we remove bar.jar, the compile works fine. Is Scala trying to save me from typing com.? Is there a way to tell it to import only what I tell it to?