隐式超构造函数object()未定义。必须显式调用另一个构造函数 [英] implicit super constructor object() is undefined. must explicitly invoke another constructor

查看:3119
本文介绍了隐式超构造函数object()未定义。必须显式调用另一个构造函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个新的错误?我有一台新的Mac电脑和在其上安装eclipse 。校验和匹配罚款。但是当我尝试创建一个简单的类,只是为了进行基本测试,我得到标题中提到的错误。从来没有看到java抱怨关于 object()构造函数。这是课程:

  package com.my.ok; 

public class First {

}

编辑:



我发现如果我将执行环境设置为 javaSE -1.7



解决方案

如果您的 JRE 不是,则会出现此问题在项目内建路径中配置。



配置 JRE:



在Eclipse中




  • 右键单击在您的项目中,选择构建路径 - > 配置构建路径

  • 转到到库选项卡单击添加库

  • 选择 JRE系统库单击下一步

  • 然后选择 JRE 根据您的要求从选项。点击完成



在Netbeans中: p>


  • 右键单击项目,然后选择属性

  • 在库类别中,根据您的要求选择 Java Platform

  • 然后转到源类别选择源/二进制格式,并根据您的要求选择JDK。



说明:



错误是因为您没有将系统库您的项目和您的类无法在创建对象时找到层次结构中首先调用的 Object()构造函数。



示例:

  package com.my.ok; 

public class First {

}

发生什么是编译器默认扩展您的第一个类到对象 class

  package com.my.ok; 

public class First extends Object {

}

Object 在您的案例中找不到类,您收到此错误。


Is this a new bug? I got a new mac computer and install eclipse on it. The checksum matches fine. But when I try to create a simple class, just for basic testing, I get the error mentioned in the title. Never before have I seen java complaining about object() constructor. Here is the class:

package com.my.ok;

public class First {

}

EDIT:

I am finding that the problem happens if I set execution environment to javaSE-1.7

解决方案

This problem occurs if your JRE is not configured in project built path.

To configure JRE:

In Eclipse:

  • Right click on your project and select Build Path -> Configure Build Path
  • Go to Libraries tab click Add Library.
  • Select JRE System Library click Next
  • Then select JRE from options as per your requirement. Click Finish

In Netbeans:

  • Right Click on the Project and select Properties.
  • In the Library category select Java Platform as per your requirement.
  • Then go to Source category select Source/Binary Format and select JDK as per your requirement.

Explanation:

The error was because you did not include System libraries in your project and your class was not able to find Object() constructor which is called first in the hierarchy when you create an object.

Example:

package com.my.ok;

public class First {

}

what happens is compiler extends by default your First class to Object class

package com.my.ok;

public class First extends Object {

}

but Object class was not found in your case and you were getting this error.

这篇关于隐式超构造函数object()未定义。必须显式调用另一个构造函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆