Deal with Duplicate Class Error

While executing some code in the Java you may come across Duplicate Class Error.

Rename the Classes

This situation arises when two different Jar Files (.jar) contain classes with the same name. For example: dist/Project1.jar and dist/lib/Project2.jar are two Jar Files which contain classes having the same name, i.e. com.packagename.Class1.class In that case please rename a class from either jars so that both will have different names.

Reinstall the Java

Uninstall and reinstall the Java software. The steps are given below:

For Windows 8.1/ 8:

1. Press Windows Key + X.

2. Click “Programs and Features”.

3. Right click Java from the installed programs list.

4. Choose Uninstall.

5. Follow the wizard, reboot.

6. Download the setup online and install the program again.

7. Download Java online.

For Earlier Versions of Windows:

1. Click the Start button.

2. Type “Uninstall a program” in the Search Box.

3. Press ENTER.

4. Refer Steps # 3-7 from Windows 8.1/ 8 user’s paragraph.

 

Download Latest Version of Java

There could be several bugs in the outdated Java version. Download and install the latest version online and then execute your code again.

 

Delete Java Temporary Files

Java has temporary files stored in particular folder(s) so that they’re accessed from time to time. Delete all temporary files to resolve the problem.

For Windows 8.1/ 8:

1. Press Windows Key + X.

2. Click Control Panel.

3. Click Java Control Panel.

4. In the new dialog click the General tab.

5. Under Temporary Internet Files frame click Settings button.

6. Click Delete Files button.

7. Confirm the action.

8. Reboot the machine when you’re done.

 

Clear the NetBeans Cache

If you’re getting Duplicate Class error with NetBeans software, please clear the cache as shown below:

For Windows 8.1/ 8 and Earlier Versions:

1. Double click Computer desktop icon.

2. Open the following directory:

C:\Users\<YourUserName>\AppData\Local\NetBeans\Cache\7.2

3. Delete all the cache contents.

Note: The AppData folder is hidden. Unhide it as shown below:

For Windows 8.1/ 8:

1. In My Computer window click the View tab.

2. Check-up “Hidden items” checkbox.

For Earlier Versions of Windows:

1. Click Tools menu, select Folder Options.

2. Click the View tab.

3. Select “Hidden files, folders and drives” option.

4. Click Apply | OK.

 

Change Annotation Processor Settings

1. Open your Java project that contains a file named APTDemo.jar.

2. Launch Project Properties dialog.

3. Click Annotation Processing panel or Java Compiler, whichever option is present.

4. Check-up “Annotation processing” checkbox.

5. Specify the following values:

Processor Path: androidannotations-2.7.jar

Production Sources Path: aa-gen

Test Sources Path: aa-gen-tests

6. Save the generated sources.

7. Specify following value:

Source: aa-gen

8. Re-build your project and it’ll work fine.

 


Warning: Undefined array key "author_box_bio_source" in /home1/clonefil/public_html/blog/wp-content/plugins/molongui-authorship/views/author-box/parts/html-bio.php on line 2

I am director and business manager at Sorcim Technologies. The product Clone Files Checker, this blog, and the content written for the blog are the properties of Sorcim. We are responsible for the content and we are always willing to answer your queries about our solutions. We encourage you to contact us should you have any questions!

We are into IT since 2004. We love to make software programs, web-services and mobile applications that solve various computing problems.