# "main" as name of method causes "Target VM failed to initialize" error

**URL:** <https://discourse.processing.org/t/main-as-name-of-method-causes-target-vm-failed-to-initialize-error/300>\
**Category:** Processing\
**Created:** [May 23, 2018, 5:54pm UTC](https://discourse.processing.org/t/main-as-name-of-method-causes-target-vm-failed-to-initialize-error/300 "2018-05-23T17:54:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![AFNordal](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@AFNordal](https://discourse.processing.org/u/AFNordal)\
**Post date:** [May 23, 2018, 5:54pm UTC](https://discourse.processing.org/t/main-as-name-of-method-causes-target-vm-failed-to-initialize-error/300/1 "2018-05-23T17:54:10Z")

</div>

I discovered a problem when I used the name `main` for a class method; it made the sketch not run and gave me this error:

```auto
Usage: PApplet [options] <class name> [sketch args]
See the Javadoc for PApplet for an explanation.
Could not run the sketch (Target VM failed to initialize).
For more information, read revisions.txt and Help ? Troubleshooting

```

Is this a bug or just me being a noob?

---

<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:** [May 23, 2018, 6:00pm UTC](https://discourse.processing.org/t/main-as-name-of-method-causes-target-vm-failed-to-initialize-error/300/2 "2018-05-23T18:00:36Z")

</div>

It’s you being a noob. 🤣

Actually, you now know too much for your own good. You have discovered that Processing is cheating on you! If you pull back the curtain, you’ll find that there are a lot of details that Processing automagically deals with, so that you - or rather people even more new than you - just don’t have to worry about them.

For example… Processing’s `setup()` and `draw()` functions just… work! Right? Well, yes. But that’s because what’s really happening is they are both getting included as functions within a hidden, higher up-in-scope java class (that you normally wouldn’t even notice). And that hidden class has the main() method in it that makes them work magically.

But when you name a method main(), that method gets in that hidden main()'s way. You’re stepping on toes that you can’t even see!

For now, close the curtain and call your method something else. Might I suggest `core()`?

---

<div class="post-metadata">

**Author:** ![AFNordal](https://avatars.discourse-cdn.com/v4/letter/a/4af34b/32.png) [@AFNordal](https://discourse.processing.org/u/AFNordal)\
**Post date:** [May 23, 2018, 6:02pm UTC](https://discourse.processing.org/t/main-as-name-of-method-causes-target-vm-failed-to-initialize-error/300/3 "2018-05-23T18:02:49Z")

</div>

I guess I suspected something along those lines… Thanks a lot!

---

<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:** [May 23, 2018, 8:01pm UTC](https://discourse.processing.org/t/main-as-name-of-method-causes-target-vm-failed-to-initialize-error/300/4 "2018-05-23T20:01:37Z")

</div>

[https://en.WikiBooks.org/wiki/Computer\_Programming/Hello\_world#Java](https://en.WikiBooks.org/wiki/Computer_Programming/Hello_world#Java)

```java
class HelloWorld {
     public static void main(String[] args) {
          System.out.println("Hello, world!");
     }
}

```
