# Difficulty of running code when compacting sketch into a ZIP-file

**URL:** https://discourse.processing.org/t/difficulty-of-running-code-when-compacting-sketch-into-a-zip-file/33113
**Category:** Coding Questions
**Created:** [October 27, 2021, 2:43pm UTC](https://discourse.processing.org/t/difficulty-of-running-code-when-compacting-sketch-into-a-zip-file/33113 "2021-10-27T14:43:08Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![William](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@William](https://discourse.processing.org/u/William)
#### Post date: [October 27, 2021, 2:43pm UTC](https://discourse.processing.org/t/difficulty-of-running-code-when-compacting-sketch-into-a-zip-file/33113/1 "2021-10-27T14:43:08Z")

</div>

So, I have completed an animation with a custom background picture i.e. a picture of a google search. It runs normal & fine on my laptop but when I compremise it into a ZIP-file to send it to my supervisor, I get constantly the same error repeatedly

First, this is the animation I am doing:

PImage space\_is\_amazing; //defining the background picture as “spaceisamazing”.

int Main\_Star\_Diameter = 400; // self-explanatory definition for the origin star’s diameter.

int Moon\_Diameter = 20; //The diameter of the moon added orbiting the earthlike planet.

int Patros = 40; //The diameter of the first rocky planet.

int Tetao = 60; //The diameter of the second rocky planet.

int b\_h\_dr = 5; // the blackhole diameter.

int Ast\_dr = 8; // The diameter of the manipulating asteroids.

float XCo\_S = 900.5; //displaying the x-position of the origin star.

float YCo\_S = 450.5; //displaying the y-position of the origin star.

float YCo\_FRS = 200.5; //This specific integer is defined as the starting y-coordinate for the random blue stars.

float ElP\_Dr = 70.5; //The diameter of the earthlike planet added into the animation.

float Rs\_Dr = 7.5; //The diameter of the random light blue stars added into the project.

float Influentical\_planet\_dr = 20.5; //The diameter of the own manipulative planet in the last section of this animated project.

void setup()  
/_The setup of this animation is the formation of the background picture & to confirm readjustment of it’s dimensions to that of the actual display window._/  
{  
size(1920, 1080);  
space\_is\_amazing=loadImage(“backgroundpicture.jpg”);  
background(space\_is\_amazing);  
space\_is\_amazing.resize(1920, 1080);  
}

//The following coding in ‘void draw’ represents the other following applied methods.  
void draw() {  
/\*The following methods below demonstrate each individual voids within the space animation. \*/  
Manipulate\_random\_asteroids();  
Manipulate\_own\_random\_planet();  
Draw\_random\_stellar\_black\_holes();  
Draw\_massive\_gas\_giant();  
Draw\_earth\_like\_planet\_and\_moon();  
Draw\_random\_rocky\_planets();  
Draw\_random\_stars\_in\_background();  
Draw\_origin\_star();  
}

void Draw\_origin\_star()  
{  
fill(255, 204, 0);  
ellipse(XCo\_S, YCo\_S, Main\_Star\_Diameter, Main\_Star\_Diameter); // the origin star in the middle of the animation.  
strokeWeight(3); //strokeweight of the origin star.  
}

void Draw\_massive\_gas\_giant()  
/_This code creates a massive hydrogen gas-filled giant with extremely low temperatures due to it’s large distance away from the origin star._/  
{  
fill(0, 0, 255);  
ellipse(1700, 200, 200, 200);  
}

void Draw\_earth\_like\_planet\_and\_moon()  
{  
fill(51, 204, 204);  
ellipse(500, 400, ElP\_Dr, ElP\_Dr); //code with color definition for the earthlike planet.  
fill(150, 150, 150);  
ellipse(420, 420, Moon\_Diameter, Moon\_Diameter);//code representing the small moon orbiting around the planet.  
}

void Draw\_random\_rocky\_planets()  
{  
fill(192, 192, 192);  
ellipse(800, 700, Patros, Patros); //showcases the first rocky planet added to the stellar system.  
fill(128, 128, 0);  
ellipse(1300, 400, Tetao, Tetao); //showcases the second rocky planet added to the stellar system.  
}

void Draw\_random\_stars\_in\_background()  
/_This code acquires a loop to fulfil it’s purpose by adding multiple stars in one consistent y-positioning dimension with a constant distance of += 100_/  
{  
int i = 90;  
while ( i \<= 490 )

{  
fill(204, 255, 255);  
ellipse(30, i, Rs\_Dr, Rs\_Dr);  
i += 100;  
}  
}

void Draw\_random\_stellar\_black\_holes()  
/_This nested loop showcases two stellar blackholes in certain distances apart from eachother in both x & y position; increasing their diameter aids visibility but in terms of theoretical accuracy remained small._/  
{  
for (int y = 1; y \< 3; y++)  
for (int x = 1; x \< 3; x++)  
{  
fill(0);  
ellipse(200_x, 200_y, b\_h\_dr, b\_h\_dr);  
}  
}

void Manipulate\_random\_asteroids()  
/_This allows you to draw random asteroids & orbit them for individual subjectivity; my personal is to orbit around outside the earthlike planet._/  
{  
if (mousePressed && mouseX \>= 1200 && mouseX \<= 1920 && mouseY \<= 500)  
{  
fill(51, 51, 51);  
ellipse(mouseX, mouseY, Ast\_dr, Ast\_dr);//This statements allows the user to toy around the asteroids’ displacements given the boundary condition is confirmed.  
frameRate(40); //This is to slow down the animation framerate of deploying the asteroids.  
} else  
{  
background(space\_is\_amazing); /\*If the initial condition is not fulfilled, then the asteroids will disappear in the animation. \*/  
}  
}

void Manipulate\_own\_random\_planet()  
/\* This animated procedure should simulate roughly the occurence of a planet approaching a stellar object and it’s colour chance representing the temperature influence of the manipulative ellipse. \*/  
{  
if (mousePressed && mouseX \>= 600 && mouseX \<= 800)  
{  
fill(255, 102, 0);  
ellipse(mouseX, mouseY, Influentical\_planet\_dr, Influentical\_planet\_dr);  
} else if (mousePressed && mouseX \<= 600 && mouseX != 100 && mouseX \> 300 ) {  
fill(255, 153, 0);  
ellipse(mouseX, mouseY, Influentical\_planet\_dr, Influentical\_planet\_dr);  
} else if (mousePressed && mouseX \<= 300)  
{  
fill(204, 255, 204);  
ellipse(mouseX, mouseY, Influentical\_planet\_dr, Influentical\_planet\_dr);  
} else  
{  
fill(204, 255, 204);  
ellipse(60, 80, Influentical\_planet\_dr, Influentical\_planet\_dr);  
}  
}

And the error I always get, is this:

_The file “backgroundpicture.jpg” is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable._  
_NullPointerException_  
_Could not run the sketch (Target VM failed to initialize)._  
_For more information, read Help ? Troubleshooting._

I hope, someone could help me out with this since I have to submit this in a week 😬

Sincerely,  
William.

---

<div class="post-metadata">

### Author: ![paulgoux](https://avatars.discourse-cdn.com/v4/letter/p/b9bd4f/32.png) [@paulgoux](https://discourse.processing.org/u/paulgoux)
#### Post date: [October 27, 2021, 2:55pm UTC](https://discourse.processing.org/t/difficulty-of-running-code-when-compacting-sketch-into-a-zip-file/33113/2 "2021-10-27T14:55:41Z")

</div>

Running from a zip file if you have assets or multiple pde files isn’t recommended. A zip file is to most programs just that a zip File. Meaning there is no folder structure meaning any symbolic link to assets will be inaccessible

---

<div class="post-metadata">

### Author: ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)
#### Post date: [October 27, 2021, 7:12pm UTC](https://discourse.processing.org/t/difficulty-of-running-code-when-compacting-sketch-into-a-zip-file/33113/3 "2021-10-27T19:12:42Z")

</div>

Hi @William,

Welcome to the forum! 😉

If you compress your project, make sure you also compress both the `.pde` files and the `data` folder where all your images should be.

If you unzip your archive, you should have your folder with your code and assets inside.

The error you had comes from the fact Processing can’t load your image from the `data` folder.

---

<div class="post-metadata">

### Author: ![William](https://avatars.discourse-cdn.com/v4/letter/w/b19c9b/32.png) [@William](https://discourse.processing.org/u/William)
#### Post date: [November 30, 2021, 7:49pm UTC](https://discourse.processing.org/t/difficulty-of-running-code-when-compacting-sketch-into-a-zip-file/33113/4 "2021-11-30T19:49:48Z")

</div>

Cheers man,  
I am so sorry for the late reply but I have figured it out on my own. HOWEVER, your approach was exactly identical to mine.

Much appreciated!
