method must call super() error in Netbeans

孤人 提交于 2019-11-27 05:34:44

I saw these symptoms just the other day.

I had I file I had been editing and decided I wanted to split my changes into 2 commits. I went to the directory containing my file "x/y/Z.java", made a directory in "x/y" named "backup", moved "Z.java" there, and pulled a fresh copy from version control. Note all of this was done outside the IDE.

Back in the IDE I merged in the changes for the first commit and when I built I got the duplicate class message for "Z.java".

When I copied the source to "backup" I did it outside the IDE and it still had the original package "x.y" as did my newly edited "Z.java". NB would not compile the new "Z.java" because it could see it had already created "x.y.Z.class" (from "x/y/backup/Z.java").

There are 2 ways to fix this:

  1. Rename "x/y/backup/Z.java" to "x/y/backup/Z.java.backup". (Prevent the backup copy from being compiled.)
  2. Change the package in "x/y/backup/Z.java" from "x.y" to "x.y.backup". (Make the backup create a different class file.)

After making either of these changes, perform a "clean and build". Note: simply building will not fix the problem, you need to perform a clean to remove the rogue class file.

Note: #1 was done by renaming Z.java from the command line, not within NB. NB will not let you change the file extension.

I found that renaming the package did not work, the old package was still there.

The problem for me started when I copied a package from another application into the current application, which already had a package with the same name. I was trying to add some missing classes to the package. After I did that, the error started.

To resolve it, I deleted the entire package from the target web app and did a clean and build. Then I copied the source package into the target application. No errors.

Cleaning and Building solves the problem

If you still have the problem, this is how I solved it..

In my case I changed the class with main method later and the initial class was still referenced in the proporties file.

Change that setting, clean and build.. It worked for me...

In my case, i had the same problem in a Web application after making an external copy of a POJO and manually editing it outside NETBEANS. The problem actually was what the others suggested in other answers about a conflict in the already compiled .class files.

What i did to overcome this was simply delete the folder webAppname/WEB-INF/classes (where compiled classes reside) and then do a Clean and Build

Hope this helps someone

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!