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
There are two ways to resolve this error. Define an explicit default constructor in parent class. As stated before, if a class contains a constructor, the compiler does not automatically generate default constructor. Explicitly invoke parent class constructor from within the child constructor using super() .
implicit super constructor is undefined for default constructor. must define an explicit constructor” this compilation error is caused because the super constructor is undefined. in java, if a class does not define a constructor, compiler will insert a default one for the class, which is argument-less.
This problem occurs if your JRE
is not configured in project built path.
To configure JRE:
In Eclipse:
Build Path
-> Configure Build Path
Libraries tab
click Add Library
.JRE System Library
click Next
JRE
from options as per your requirement. Click Finish
In Netbeans:
Properties
.Java Platform
as per your requirement. 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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With