Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java - duplicate class

Tags:

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.

like image 553
Robbo_UK Avatar asked Oct 11 '13 12:10

Robbo_UK


People also ask

How do you duplicate a class in Java?

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.

How do you fix a duplicate class error in 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.

What is duplicate class?

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.

How do I fix a duplicate class error?

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.


1 Answers

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.

like image 73
Eduardo Dennis Avatar answered Dec 03 '22 00:12

Eduardo Dennis