Question: We are programming a game, which shall be startable from a .jar file. First we created a Project in IntelliJ and loaded the Images from a ZIP with the following code:

```
ZipFile zf = null;
try {
    zf = new ZipFile(zipPath);
    Image Image = ImageIO.read(zf.getInputStream(zf.getEntry("Block/Air.png")));
} catch (IOException ignored) {}

```

Now the attempt without the ZIP (just from the .jar) is:

```
Image image=ImageIO.read(getClass().getResourceAsStream(path+ "Block/Air.png"));

```

It doesn't load any texture. Do you have a better way to do this in combination?

Edit:Seems not to be the Problem.

Answer: 
Since jars are zip files you could place them in the jar file and placing them the classpath.

```
Image image=ImageIO.read(getClass().getResourceAsStream(path+ "Block/Air.png"); 

```

Path must be a relative path from a source path root. E.g. I have a file in "src/main/resource/my/cool/game/" path is "/my/cool/game".

If you want to use a zip file, it must be outside of your jar file. To load the zip, you could use a relative file path, which is the same if you start your game from Intellij and from dekstop. 

To change the working directory in intellij [look here](https://www.jetbrains.com/idea/help/run-debug-configuration-application.html).

The best way would be to place the zip file alongside the jar so you can use "." as working directory to load the zip file.

Alternatively you could use a fixed directory, but then your game needs some sort of installation so it knows where to finde the zip file.

If you use ".", the zip file needs to be in the root of the project directory.
Why do you need to store your images in a zip file? If you're doing it to reduce the file size, you gain absolutely nothing from zipping it first. JAR files are zipped files anyway (if you don't believe me, rename your .jar file to .zip, and try to open it). What you're basically doing is attempting to zip an already zipped file, which doesn't really do anything.

I would recommend you unzip your images and store them somewhere like < resources >/images

If you insist on leaving them zipped, you'll need to change it to something like this. Otherwise, it's looking for the zip file in the working directory (directory from which the jar was executed)

```
ZipFile zf = new ZipFile(getClass().getResourcesAsStream("path/to/zip"));

```

Disclaimer: I am not familiar with the ZipFile class, so I do not know if that constructor exists.