0

I created a simple project using the LWJGL libraries in Intellij IDE. The game runs fine inside the IDE, but I've run into problems when trying to create an executable JAR file. After trying to manipulate Intellij to do it for me and failing, I've switched to using JarSplice.

I've been able to correctly load the LWJGL jar files, as well as all the natives needed to run. However, when launching the file with java -java project.jar, I receive an error when trying to read my shader source code. I believe the problem is the executable JAR created with JarSplice is not able to find these files. Below is the error I received:

java.io.FileNotFoundException: src/shaders/vert.shader (No such file or directory)
    at java.io.FileInputStream.open(Native Method)
    at java.io.FileInputStream.<init>(FileInputStream.java:146)
    at java.io.FileInputStream.<init>(FileInputStream.java:101)
    at java.io.FileReader.<init>(FileReader.java:58)
    at utilities.LWJGLFile.toString(LWJGLFile.java:21)
    at utilities.ShaderProgram.loadShader(ShaderProgram.java:42)
    at utilities.ShaderProgram.<init>(ShaderProgram.java:26)
    at game.LWJGLGame.setupOpenGL(LWJGLGame.java:260)
    at game.LWJGLGame.init(LWJGLGame.java:81)
    at game.LWJGLGame.<init>(LWJGLGame.java:48)
    at main.Main.main(Main.java:22)

The source code at this point in the code looks like this: String source = LWJGLFile.toString("src/shaders/".concat(file)); where file is either "frag.shader" or "vert.shader".

How would I change the file path so the project will work properly on any machine?

user3709119
  • 107
  • 11
  • You sure that the file in the "src/shaders" folder? Also http://stackoverflow.com/questions/5171957/access-file-in-jar-file might help. – KriszDev May 04 '15 at 20:07
  • Yeah, I have 2 files in that folder and it runs fine when running from Intellij. However, when trying to run it after making the file with JarSplice, that's when I get the error. Is there a specific way of adding these files into JarSplice? I also tried those solutions, but they failed for me. – user3709119 May 05 '15 at 01:18

0 Answers0