Closed ryansnewell closed 7 years ago
Thank you! I will fix this today!
Added main class to the manifest. First part of issue is fixed, but the main class is still not found, don't know why.
I tried adding a new class with a main method in the same package as LastTry.java and the new file was able to be run. In the new main file I called the main() method of LastTry and got the following:
Exception in thread "main" java.lang.NoClassDefFoundError: org/newdawn/slick/state/StateBasedGame
at java.lang.ClassLoader.defineClass1(Native Method)
...
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.egordorichev.lasttry.Main.main(Main.java:6)
Caused by: java.lang.ClassNotFoundException: org.newdawn.slick.state.StateBasedGame
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 13 more
So it seems like StateBasedGame cannot be found but not sure why it would build successfully if this was the case. I was able to solve this by using the maven shaded plugin which puts all the dependencies in the one jar, and then the new error is:
Exception in thread "main" java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1867)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1122)
at org.lwjgl.Sys$1.run(Sys.java:72)
at java.security.AccessController.doPrivileged(Native Method)
at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
at org.lwjgl.Sys.loadLibrary(Sys.java:96)
at org.lwjgl.Sys.<clinit>(Sys.java:117)
at org.lwjgl.opengl.Display.<clinit>(Display.java:135)
at org.newdawn.slick.AppGameContainer$1.run(AppGameContainer.java:39)
at java.security.AccessController.doPrivileged(Native Method)
at org.newdawn.slick.AppGameContainer.<clinit>(AppGameContainer.java:36)
at org.egordorichev.lasttry.LastTry.main(LastTry.java:177)
at org.egordorichev.lasttry.Main.main(Main.java:6)
Not sure why it compiles with dependencies but can't find them when I run it.
Are the dependencies included in the built jar file? If not, are you adding them to the class path?
I think the maven file is completely broken. I will try to generate a new one.
Ok, i've figured out the first part of the error. The LastTry
class, witch has the main()
method, is extended from StateBasedGame
. Moving main()
to another class fixed it.
But now it looks like it doen't pack the dependencies right.
Sorry for this error, we are building using IDE and installed libs. Trying to figure out, why it does not pack the dependencies.
Finally got it. Added "-Djava.library.path=lib/macosx/" to the command line when running and it worked.
Oh, great! Thank you! Will add that to the README.
I have tried to build and run the project on both my Mac and Windows and have gotten the same errors on both computers. I followed the steps in the Readme and I can get "mvn package" to run. But after that I can't get anything to work.
target>java -jar lasttry-1.0.0-SNAPSHOT.jar
no main manifest attribute, in lasttry-1.0.0-SNAPSHOT.jar
I have tried several variations of this including being in the target folder, out of it and using an absolute path, quotes, even trying to run the main class using the jar as the classpath:
target>java -cp lasttry-1.0.0-SNAPSHOT.jar org.egordorichev.lasttry.LastTry
Error: Could not find or load main class org.egordorichev.lasttry.LastTry
The only warnings I get while running maven is that it's using platform encoding, could this be it? Where is the main manifest? Or how do I get it to generate properly?