Skip to content

Commit 406bd0d

Browse files
committed
fixing the "image not loading inside jar".
1 parent ce94a85 commit 406bd0d

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/Ant.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public Ant(Tile start, Tile goal, int tileSize, Tile[][] tiles) {
3636

3737
private void loadAntImg() {
3838
try {
39-
antImage = ImageIO.read(new File("assets/images/ant.png"));
39+
antImage = ImageIO.read(getClass().getResource("assets/images/ant.png"));
4040
} catch (IOException e) {
4141
e.printStackTrace();
4242
}

src/Game.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public Game() {
9696

9797
private void loadFoodImg() {
9898
try {
99-
foodImg = ImageIO.read(new File("assets/images/food.png"));
99+
foodImg = ImageIO.read(getClass().getResource("assets/images/food.png"));
100100
} catch (IOException e) {
101101
e.printStackTrace();
102102
}

0 commit comments

Comments
 (0)