# How do I access outer class I made?

**URL:** https://discourse.processing.org/t/how-do-i-access-outer-class-i-made/29848
**Category:** Beginners
**Created:** [May 4, 2021, 9:32am UTC](https://discourse.processing.org/t/how-do-i-access-outer-class-i-made/29848 "2021-05-04T09:32:35Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Menchi](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@Menchi](https://discourse.processing.org/u/Menchi)
#### Post date: [May 4, 2021, 9:32am UTC](https://discourse.processing.org/t/how-do-i-access-outer-class-i-made/29848/1 "2021-05-04T09:32:35Z")

</div>

Hi, i’m newbie to p5.js, and I just want to reproduce this simple code : [https://www.youtube.com/watch?v=17WoOqgXsRM](https://www.youtube.com/watch?v=17WoOqgXsRM)

I’ve set up my p5 environment on Atom editor with local server to see my results on browser.  
So I have my main class sketch.js and an outer class Star and I want to instantiate Star object in my main class but I got unexpected identifier error for ‘Star’ in my console. I thought by adding `<script src="Star.js"></script>` in index.html would solve the problem but it didn’t.

I need to import this class but I don’t how. Thanks for the help in advance !

---

<div class="post-metadata">

### Author: ![Menchi](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@Menchi](https://discourse.processing.org/u/Menchi)
#### Post date: [May 4, 2021, 9:48am UTC](https://discourse.processing.org/t/how-do-i-access-outer-class-i-made/29848/2 "2021-05-04T09:48:42Z")

</div>

Sorry, it’s a mistake I think, the class has been correctly imported. The error is something else but I can’t understand what. Here’s a picture of my console :

 ![Capture](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/8/8a30e2101557696d78b6b625f045db361461b965.png)

---

<div class="post-metadata">

### Author: ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)
#### Post date: [May 4, 2021, 12:51pm UTC](https://discourse.processing.org/t/how-do-i-access-outer-class-i-made/29848/4 "2021-05-04T12:51:13Z")

</div>

Welcome to the forum!

It would be great if you can share entire the code although I can see a portion in your screenshot.

From what I see in the image, it’s not how it works in JavaScript. It has quite different syntax from Java, and you cannot simply copy & paste to make it work. You might want to watch some tutorials on the Coding Train to learn p5.js:

[![](https://img.youtube.com/vi/T-HGdc8L-7w/maxresdefault.jpg "6.2: Classes in JavaScript with ES6 - p5.js Tutorial") ](https://www.youtube.com/watch?v=T-HGdc8L-7w)

Also if you want the answer, in fact the Coding Train already made a p5.js version of the starfield, which you can find on their website:

> **[Starfield in Processing](https://thecodingtrain.com/challenges/1-starfield/)**
>
> This is the first in a new series of videos. In this video I attempt to program a "star field" or "warp speed" visualization in Processing.

---

<div class="post-metadata">

### Author: ![Menchi](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@Menchi](https://discourse.processing.org/u/Menchi)
#### Post date: [May 4, 2021, 2:37pm UTC](https://discourse.processing.org/t/how-do-i-access-outer-class-i-made/29848/5 "2021-05-04T14:37:20Z")

</div>

Thank you, yes for a first post it is not clear at all, I will do better next time by adding all the code and complete description.

Ohh ok ! I watched the video of the Coding Train “Coding challenge number 1” but I did not understand that it was in java and not in javascript, I feel stupid for that ^^’

Thanks a lot !

---

<div class="post-metadata">

### Author: ![micuat](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/micuat/32/19407_2.png) [@micuat](https://discourse.processing.org/u/micuat)
#### Post date: [May 4, 2021, 5:27pm UTC](https://discourse.processing.org/t/how-do-i-access-outer-class-i-made/29848/6 "2021-05-04T17:27:40Z")

</div>

no problem! I think the newer episodes of the coding challenges are in p5.js, but most of them have p5.js versions even if they were originally coded in processing (java) 🙂
