Eclipse scala.object cannot be resolved

21,784

Solution 1

UPDATED 4/26/2018

It appears that you need to have the Scala runtime library in your Eclipse project's classpath.

If you're using Maven (or some other repository-based build tool—highly recommended), then adding Kafka as a dependency should cause it to automatically download the corresponding Scala runtime library and include it on your project's classpath. For example,

<dependency>
    <groupId>org.apache.kafka</groupId>
    <artifactId>kafka_2.12</artifactId>
    <version>1.1.0</version>
</dependency>

will cause Maven to download version 2.12.4 of the Scala runtime library.

Otherwise, you can install Scala (see http://scala-lang.org/) and add the installed scala-library.jar to your project's classpath manually. However, you should note that Scala minor releases (2.10.x, 2.11.x, 2.12.x, etc.) are not binary compatible with each other, so you should download the most recent bug-fix version of the minor release used to build your version of Kafka. (This minor version is appended to the name of the Kafka artifact, e.g. kafka_2.12 requires a Scala 2.12.x runtime library version.)

Solution 2

Downloaded the scala libraries from http://scala-lang.org/download/ and added the scala-library.jar to the project, error resolved!

Share:
21,784
B.Mr.W.
Author by

B.Mr.W.

SOreadytohelp I am a business data analyst who use R and Python. Started recently learning Apache Spark. I am a firm believer of open source software.

Updated on July 09, 2022

Comments

  • B.Mr.W.
    B.Mr.W. almost 2 years

    I am trying to write Kafka producer and consumer code in Java using Eclipse. I am have downloaded the Kafka jar file and loaded as external Jar file. And it solved the dependency problem.

    However, there is always a unresolved error and the message looks like below:

    Multiple markers at this line
    - The type scala.Product cannot be resolved. It is indirectly referenced from required .class files
    - The type scala.Serializable cannot be resolved. It is indirectly referenced from required .class 
     files
    

    I really don't know what is going on and how to fix that error. Thanks.

    enter image description here

  • anastaciu
    anastaciu about 4 years
    Id details don't belong in the answer, you can change your username and location in your personal settings, also, caps are not needed.