I've followed the advice of other solutions. Like this one.
I've also tried the solution belonging to this
$ java -cp app.jar main.Main
I get an error that would not normally occur when running the project inside of IntelliJ.
Here is that error:
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "java.awt.image.BufferedImage.getSubimage(int, int, int, int)" because "img" is null
at entities.MiqoCharacter.loadAnimationMale(MiqoCharacter.java:280)
at entities.MiqoCharacter.<init>(MiqoCharacter.java:50)
at gamescreens.CharacterDisplayScreen.initClasses(CharacterDisplayScreen.java:33)
at gamescreens.CharacterDisplayScreen.<init>(CharacterDisplayScreen.java:27)
at main.Game.initClasses(Game.java:33)
at main.Game.<init>(Game.java:22)
at main.Main.main(Main.java:7)
Like I have stated, this error does not occur inside of the program itself. I believe that it has to do with the resources folder. This is the method that is causing the errors.
public static BufferedImage GetSpriteAtlas(String fileName) {
BufferedImage img = null;
InputStream is = AssetLoader.class.getResourceAsStream(fileName);
if (is != null) {
try {
img = ImageIO.read(is);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return img;
}
When running the full code inside of IntelliJ, I can see the program just fine. Here is the GUI of the application displaying correctly when running inside of IntelliJ.
I have created the .jar file using IntelliJ, and I have built it using Gradle. this is my build.gradle file.
plugins {
id 'java'
}
jar {
manifest {
attributes "Main-Class": "main.Main"
}
}
group 'org.example'
version '1.0-SNAPSHOT'
repositories {
mavenCentral()
}
dependencies {
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}
test {
useJUnitPlatform()
}
and here is my MANIFEST.MF
Main-Class: main.Main
I've tried to follow the advice of several threads on stack overflow as well as from videos on youtube. I can't seem to find the answer to this. And i get errors that would indicate that my .jar file had not compiled the contents of the resource folder, nor detect the Main class in my project.