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 the editor. */ package database_console; import java.sql.Connection; import java.sql.DriverManager; import java.sql.SQLException; /** * * @author davidsonr */ public class DBConnect { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here } }
Netbeans highlights DBConnect as red with duplicate class error.
Creating a copy using the clone() method The class whose object's copy is to be made must have a public clone method in it or in one of its parent class. Every class that implements clone() should call super. clone() to obtain the cloned object reference. The class must also implement java.
In such a case, the module is copied in the javasource folder in the app directory with a new name and the old folder is kept, resulting in two identical folders with different names. Simply delete the copied folder with the modulename that is not used and you should be fine.
The "duplicate class" error can also occur when the class is named the same with the same package naming hierarchy, even if one of the classes exists in a directory structure with directory names different than the package names.
Check it and remove any duplicate jar file. and second option could be you have also added the dependency in gradle. build and also have jar in libs folder. So check both places and remove duplicate entries and the clean and build APK again.
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.
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