java - duplicate class

前端 未结 5 1613
广开言路
广开言路 2020-12-17 10:43

Confused as to why I get duplicate class error for the following code?

/*
 * To change this template, choose Tools | Templates
 * and open the template in th         


        
相关标签:
5条回答
  • 2020-12-17 11:11

    This can also happen if the package name does not match the folder name, or if the package name is omitted. Check the package statement in your source.

    0 讨论(0)
  • 2020-12-17 11:12

    If the file name doesn't match the class name, NetBeans 8.0.1 will report this as a duplicate class.

    0 讨论(0)
  • 2020-12-17 11:15

    This also happens if your referencing the erroring class in a separate file in the same package, with the erroring class with an unmatching package path to the file where you are referencing erroring class.

    For example file 1 some.incorrect.path.package

    class_that_is_erroring{ }

    file 2 some.correct.path.package

    class new_class{

    class_that_is_erroring myclass = null;

    }

    The package paths in both files must match each other and match the file system directory.

    0 讨论(0)
  • 2020-12-17 11:19

    This is a known issue with netbeans BUG 226360



    it might help to clear Netbeans cache:

    Go to Help -> About and you will see

    Cache directory: Path\to\Directory

    Close NetBeans, go to specified directory and delete everything.

    0 讨论(0)
  • 2020-12-17 11:26

    this might be due to 2 classes with the same name in the same package

    0 讨论(0)
提交回复
热议问题