# Create class in Processing (error message)

**URL:** <https://discourse.processing.org/t/create-class-in-processing-error-message/40922>\
**Category:** Coding Questions\
**Created:** [February 14, 2023, 12:15pm UTC](https://discourse.processing.org/t/create-class-in-processing-error-message/40922 "2023-02-14T12:15:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kmll](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@kmll](https://discourse.processing.org/u/kmll)\
**Post date:** [February 14, 2023, 12:15pm UTC](https://discourse.processing.org/t/create-class-in-processing-error-message/40922/1 "2023-02-14T12:15:01Z")

</div>

I created a class in a separate TAB but I still get the “The class Test does not exist”. If I move the class code into the main tab it works fine. What do I need to do to import the class?

In main tab:

```auto
Test t1 = new Test();
t1.fname = "Per";

```

In the Test tab:

```auto
class Test{

  String fname;
  String lname;
  
  Test(){}

}

```

---

<div class="post-metadata">

**Author:** ![glv](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/glv/32/18785_2.png) [@glv](https://discourse.processing.org/u/glv)\
**Post date:** [February 14, 2023, 12:35pm UTC](https://discourse.processing.org/t/create-class-in-processing-error-message/40922/2 "2023-02-14T12:35:31Z")

</div>

Hello @kmll,

I get an error with your class in a tab or in the main tab with Processing 4.1.3

Error:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/3/6/365e195b3d7372df7b99c14e627f859e7ad0cd1a.png)

No Error:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/0/1/0111b46ed242e9bef3acecc7147255e1826d34ce.png)

This _works_ with the class in the tab or in the main tab:

```auto
void setup()
  {
  Test t1 = new Test(); // Here for testing.
  t1.fname = "Per";
  }

```

Resources here to explore:

> **[Welcome to Processing!](https://processing.org/)**
>
> Processing is a flexible software sketchbook and a language for learning how to code. Since 2001, Processing has promoted software literacy within the visual arts and visual literacy within technology…

There is a reference for _class_ and _Object_ with examples.

There is a tutorial for _Objects_.

`:)`

---

<div class="post-metadata">

**Author:** ![TfGuy44](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tfguy44/32/41_2.png) [@TfGuy44](https://discourse.processing.org/u/TfGuy44)\
**Post date:** [February 14, 2023, 5:05pm UTC](https://discourse.processing.org/t/create-class-in-processing-error-message/40922/3 "2023-02-14T17:05:05Z")

</div>

Don’t name your class the same thing as the tab it’s in. While this is usually fine in most programming languages, I’ve seen it cause problems in Processing. Just try renaming your Test tab to TestClass, and see if that helps.

This happens because Processing is hiding details from you about how things are done behind the scenes.

---

<div class="post-metadata">

**Author:** ![jafal](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jafal/32/19112_2.png) [@jafal](https://discourse.processing.org/u/jafal)\
**Post date:** [February 14, 2023, 7:40pm UTC](https://discourse.processing.org/t/create-class-in-processing-error-message/40922/4 "2023-02-14T19:40:30Z")

</div>

Hi

[![](https://img.youtube.com/vi/lmgcMPRa1qw/hqdefault.jpg "8.2: Defining a Class Part I - Processing Tutorial") ](https://www.youtube.com/watch?v=lmgcMPRa1qw&t=4s)

[![](https://img.youtube.com/vi/XwfOVFelLoo/hqdefault.jpg "8.3: Defining a Class Part II - Processing Tutorial") ](https://www.youtube.com/watch?v=XwfOVFelLoo&t=424s)

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 14, 2023, 8:57pm UTC](https://discourse.processing.org/t/create-class-in-processing-error-message/40922/5 "2023-02-14T20:57:27Z")

</div>

> [@TfGuy44](#):
>
> Don’t name your class the same thing as the tab it’s in.

Or the same name as the Sketch…!

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [February 14, 2023, 9:08pm UTC](https://discourse.processing.org/t/create-class-in-processing-error-message/40922/6 "2023-02-14T21:08:07Z")

</div>

> [@TfGuy44](#):
>
> Don’t name your class the same thing as the tab it’s in.

This is only a problem for the 1st main tab!

Other tabs can have a class or interface matching the same name as its tab.

P.S.: Actually, we can’t use the name of the 1st tab for a class or interface anywhere! ⚠

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [February 14, 2023, 9:44pm UTC](https://discourse.processing.org/t/create-class-in-processing-error-message/40922/7 "2023-02-14T21:44:46Z")

</div>

> [@kmll](#):
>
> In main tab:
> 
> ```auto
> Test t1 = new Test();
> t1.fname = "Per";
> 
> ```

Also, the 2nd line must be in a function (setup())  
and cannot stand alone outside of any function

---

<div class="post-metadata">

**Author:** ![kmll](https://avatars.discourse-cdn.com/v4/letter/k/f4b2a3/32.png) [@kmll](https://discourse.processing.org/u/kmll)\
**Post date:** [February 16, 2023, 11:53am UTC](https://discourse.processing.org/t/create-class-in-processing-error-message/40922/8 "2023-02-16T11:53:47Z")

</div>

Thank you all for advise. Works fine now 🙂
