+4 votes
by (100 points)

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.

9 Answers

+9 votes
by (100 points)

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.

+9 votes
by (100 points)

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.

+3 votes
by (100 points)

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

0 votes
by (100 points)

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 votes
by (100 points)

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

0 votes
by (100 points)

A new answer... In this case, the duplicate class error was confusing. So was part of the next error, but it also pointed to the real problem and the fix.

From my log file:

Error 1: a\g\GoodClass error:duplicate class: a.g.GoodClass //Not the problem
Error 2: a\b\BadClass error: cannot access GoodClass        //The problem
         bad source file: a\g\GoodClass                     //No, it's fine
         file does not contain class x.y.GoodClass          //How to fix it
         Please remove or make sure it appears in the correct subdirectory of the sourcepath.

Java reports the first line of Error 2 because BadClass is using a wildcarded import, either import x.*; or import x.y.*; . The java compiler found x.y.GoodClass first, so couldn't determine which you really wanted: a.g.GoodClass or x.y.GoodClass.

THE FIX: remove the wildcarded import and add the specific imports you need from library x.y.

0 votes
by (100 points)

Change sucesss to success. You are using CI framework then use CI parameterized query, don't use static query it's hackable. Give unique id to both div and select

It's better to follow MVC if you are use CI. Put your query in model with ci parameterized query.

         <div class="form-group" id = 'divtxtBusiness1'>
                            <label>Business 1</label>
                            <select name="txtBusiness1" id="txtBusiness1" style="height: 30px;width: 100%;" class="Business1">

                     <div class="form-group" id = "div_Business_2">
                            <label>Business 2</label>
                            <select name="txtBusiness2" id="business2" style="height: 30px;width: 100%;" class="Business2">
                                             <option value=""> Select Business2 </option>

                //$(document).on('change', 'select.Business1', function(){
                 //      var business1 = $('select.Business1 option:selected').val();
                $(document).on('change', '#txtBusiness1', function(){
                       var business1 = $('#txtBusiness1').val();
                       //var value = $(this).val();

                            data: { business1:business1 },
                            url: '<?php echo site_url("client_area/select_business_sub_cat"); ?>',
                            success : function (data){
                                    $('#div_Business_2 #business2').remove();

Controller :

public function select_business_sub_cat()
    $business1 = $this->input->post('business1');
    $result_sub_cat1 = $this->xyzmodel->xyzmodelfunction($business1)
    $str = '<select name="txtBusiness2" id="business2" style="height: 30px;width: 100%;" class="Business2">';
    for($i = 0 ; $i< count($result_sub_cat1) ; $i++)
           $str .= '<option value="'.$result_sub_cat1['id'].'"> '.$result_sub_cat1['name'].' </option>';

     $str .= '</select>';
     echo $str;                        
    // return $this->output->set_output($data);  

Model : don't use static query it's hackable.

class Xyzmodel extends CI_Model

    public function xyzmodelfunction($business1)
        $this->db->join("subcategory", "category.id = subcategory.category_id", 'LEFT');
        $this->db->where('category.id', $business1);
        $result = $this->db->get();
        return $result->result_array();
0 votes
by (100 points)

Pydub has a facility for getting the audio data as an array of samples , it is an array.array instance (not a numpy array) but you should be able to convert it to a numpy array relatively easily:

from pydub import AudioSegment
sound = AudioSegment.from_file("sound1.wav")

# this is an array
samples = sound.get_array_of_samples()

You may be able to create a numpy variant of the implementation though. That method is implemented pretty simply:

def get_array_of_samples(self):
    returns the raw_data as an array of samples
    return array.array(self.array_type, self._data)

Creating a new audio segment from a (modified?) array of samples is also possible:

new_sound = sound._spawn(samples)

The above is a little hacky, it was written for internal use within the AudioSegment class, but it mainly just figures out what type of audio data you're using (array of samples, list of samples, bytes, bytestring, etc). It's safe to use despite the underscore prefix.

0 votes
by (100 points)

It checks for myvar to be 0.

It translates

if (myvar === 0)
   counter = Math.ceil(counter);