# Can't display image while on VScode

**URL:** <https://discourse.processing.org/t/cant-display-image-while-on-vscode/43327>\
**Category:** Processing\
**Created:** [November 27, 2023, 7:46pm UTC](https://discourse.processing.org/t/cant-display-image-while-on-vscode/43327 "2023-11-27T19:46:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![boytedinho](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/boytedinho/32/19068_2.png) [@boytedinho](https://discourse.processing.org/u/boytedinho)\
**Post date:** [November 27, 2023, 7:46pm UTC](https://discourse.processing.org/t/cant-display-image-while-on-vscode/43327/1 "2023-11-27T19:46:56Z")

</div>

Hello! I’m having trouble displaying an image from my Processing sketch on VSCode with the follofing code:

```auto
PImage heart1;

float x,y;
float rot;

void setup() {
  size(720, 720);
  heart1 = loadImage("heart (1).PNG");
  x = 0.0f;
  y = width/2.0f;
  rot = 0.0f;
}

void draw() {
  background(255);

  translate(x,y);
  rotate(rot);
  image(heart1,0,0);

  x += 1.0;
  rot += 0.01;
  if (x > width) {
    x = 0;
  }
}

```

image files are placed inside the folder and the code works if I run it on processing, but on VS code there’s this error message:

```auto
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 0 out of bounds for length 0
        at processing.app.Sketch.getMainName(Sketch.java:1697)
        at processing.mode.java.JavaBuild.preprocess(JavaBuild.java:145)
        at processing.mode.java.JavaBuild.build(JavaBuild.java:111)
        at processing.mode.java.Commander.<init>(Commander.java:233)
        at processing.mode.java.Commander.main(Commander.java:417)

```

---

<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:** [November 28, 2023, 2:15am UTC](https://discourse.processing.org/t/cant-display-image-while-on-vscode/43327/2 "2023-11-28T02:15:32Z")

</div>

Hello @boytedinho,

Try an absolute path for the image file.

On my PC (different for you):

`heart1 = loadImage("D:/Users/mypc/Documents/P4/sketch_231127a/data/heart (1).PNG");`

`:)`

---

<div class="post-metadata">

**Author:** ![boytedinho](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/boytedinho/32/19068_2.png) [@boytedinho](https://discourse.processing.org/u/boytedinho)\
**Post date:** [November 28, 2023, 1:51pm UTC](https://discourse.processing.org/t/cant-display-image-while-on-vscode/43327/3 "2023-11-28T13:51:00Z")

</div>

@glv Thank you for the help.

Making this change showed me another error message saying there was something wrong with the sketch’s file name (it had an “-”).
