I suspect you are doing it right, but are having trouble because there’s already an “Object” class defined that’s hidden away via Processing’s magic which is having a name collision wth the Object class you are defining.
If you rename your “Object” class to “MyObject”, in all the places you use it, do you still have the same problem?