Kafka教程:java.lang.Object无法解析

huangapple 未分类评论50阅读模式
英文:

Kafka tutorial: java.lang.Object cannot be resolved

问题

我试图遵循 https://kafka.apache.org/25/documentation/streams/tutorial 进行操作,但是编译失败,出现了一堆错误。这是第一个错误:

The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

我删除了所有源文件,然后放入一个仅包含以下内容的 Pipe.java:

package myapps;

public class Pipe {

    public static void main(String[] args) throws Exception {

    }
}

但它仍然无法编译:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project streams.examples: Compilation failure: Compilation failure: 
[ERROR] /home/fatdragon/Play/kafka/streaming/streams.examples/src/main/java/myapps/Pipe.java:[1] 
[ERROR]         package myapps;
[ERROR]         ^
[ERROR] The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
[ERROR] /home/fatdragon/Play/kafka/streaming/streams.examples/src/main/java/myapps/Pipe.java:[3] 
[ERROR]         public class Pipe {
[ERROR]                      ^^^^
[ERROR] Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor
[ERROR] /home/fatdragon/Play/kafka/streaming/streams.examples/src/main/java/myapps/Pipe.java:[5] 
[ERROR]         public static void main(String[] args) throws Exception {
[ERROR]                                 ^^^^^^
[ERROR] String cannot be resolved to a type
[ERROR] /home/fatdragon/Play/kafka/streaming/streams.examples/src/main/java/myapps/Pipe.java:[5] 
[ERROR]         public static void main(String[] args) throws Exception {
[ERROR]                                                       ^^^^^^^^^
[ERROR] Exception cannot be resolved to a type
[ERROR] 4 problems (4 errors)

我正在使用 Debian Linux 映像运行,Java 版本如下:

$ java -version
openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)
英文:

I'm trying to follow https://kafka.apache.org/25/documentation/streams/tutorial

But it failed compilation with a bunch of errors. This is the first one:

The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files

I removed all source files and put in a barebone Pipe.java with the following content:

package myapps;
 
public class Pipe {
 
    public static void main(String[] args) throws Exception {
 
    }
}

And it's still not compiling:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project streams.examples: Compilation failure: Compilation failure: 
[ERROR] /home/fatdragon/Play/kafka/streaming/streams.examples/src/main/java/myapps/Pipe.java:[1] 
[ERROR]         package myapps;
[ERROR]         ^
[ERROR] The type java.lang.Object cannot be resolved. It is indirectly referenced from required .class files
[ERROR] /home/fatdragon/Play/kafka/streaming/streams.examples/src/main/java/myapps/Pipe.java:[3] 
[ERROR]         public class Pipe {
[ERROR]                      ^^^^
[ERROR] Implicit super constructor Object() is undefined for default constructor. Must define an explicit constructor
[ERROR] /home/fatdragon/Play/kafka/streaming/streams.examples/src/main/java/myapps/Pipe.java:[5] 
[ERROR]         public static void main(String[] args) throws Exception {
[ERROR]                                 ^^^^^^
[ERROR] String cannot be resolved to a type
[ERROR] /home/fatdragon/Play/kafka/streaming/streams.examples/src/main/java/myapps/Pipe.java:[5] 
[ERROR]         public static void main(String[] args) throws Exception {
[ERROR]                                                       ^^^^^^^^^
[ERROR] Exception cannot be resolved to a type
[ERROR] 4 problems (4 errors)

I'm running from a Debian Linux image with this version:

openjdk version "1.8.0_242"
OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08)
OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)


</details>


# 答案1
**得分**: 0

你的类路径中没有运行时库。&lt;br&gt;
请检查你的设置。

<details>
<summary>英文:</summary>

There is no runtime library in your classpath.&lt;br&gt;
Check your settings.

</details>



huangapple
  • 本文由 发表于 2020年7月26日 10:39:19
  • 转载请务必保留本文链接:https://java.coder-hub.com/63095545.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定