How do I distribute a LWJGL jar? - netbeans

I need help, I followed the following tutorial on setting up my project.
http://lwjgl.org/wiki/index.php?title=Setting_Up_LWJGL_with_NetBeans
And I added the following run command
-Djava.library.path='C:\Program Files (x86)\Java\lwjgl-2.8.3\native\windows'
And my project wors great in netbeans, however I can't distribute my application as I double click the jar I recieve a noClassDefFound exception.
My dist folder contains the following 2 files, no natives.
/dist/Engine.jar /dist/lib/lwjgl.jar
I am sure this is due to my natives not being included in my dist folder, I have tried searching the net and I have yet to find a solution that works, Please any help you can give me would be great, thanks.

I found a solution to my issue, I thought I would share it with others, as a lot of people seemed to have suffered like myself.
I was receiving the following exception on run,
Exception in thread "main" java.lang.NoClassDefFoundError: engine2D/engine/Engin
e
at Engine2D.Game.<init>(Game.java:42)
at Engine2D.Game.main(Game.java:48)
Caused by: java.lang.ClassNotFoundException: engine2D.engine.Engine
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 2 more
This was due to case-sensitivity which was ignored by netbeans, so whenever
engine2d.engine.Engine
was invoked it referenced the following.
Engine2D.engine.Engine
But when ran locally, I hope this helps others and I can get back to working on my game.
Thanks Gary

Related

Getting "Class Not Found" error while trying to set up a new JUNIT class in Eclipse

While setting up a JUNIT class for a uni project I keep getting the following error (working in Eclipse Oxygen):
Class not found UnitTest
java.lang.ClassNotFoundException: UnitTest
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClass(RemoteTestRunner.java:688)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.loadClasses(RemoteTestRunner.java:421)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:444)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Cant really figure out whats going on, already tried a few question-related answers like clean up the project and checking that the test is running from my project/bin folder.

Cant' load .ogg music files into Eclipse project in Slick2D

Hi I'm very new here and I,m learning how to use Slick2D game library. I'm using Eclipse Luna IDE for coding. Everything was working fine till now but when I tried to load a music with ".ogg" extension, the problem occured.
I try to load a music by this line of code
music = new Music( "res/game_music.ogg" );
An exception occurs like this,
AL lib: FreeContext: (000000000E2F08A0) Deleting 64 Source(s)
Exception in thread "main" java.lang.NoClassDefFoundError: com/jcraft/jorbis/Info
at org.newdawn.slick.openal.OggInputStream.<init>(OggInputStream.java:35)
at org.newdawn.slick.openal.OggDecoder.getData(OggDecoder.java:311)
at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:835)
at org.newdawn.slick.openal.SoundStore.getOgg(SoundStore.java:793)
at org.newdawn.slick.Music.<init>(Music.java:135)
at org.newdawn.slick.Music.<init>(Music.java:74)
at main.Game.init(Game.java:48)
at org.newdawn.slick.AppGameContainer.setup(AppGameContainer.java:390)
at org.newdawn.slick.AppGameContainer.start(AppGameContainer.java:314)
at main.Game.main(Game.java:33)
Caused by: java.lang.ClassNotFoundException: com.jcraft.jorbis.Info
at java.net.URLClassLoader$1.run(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
... 10 more
I can assure you that
1. I've looked on the internet for enough time to find a solution and surprisingly I could not find anything helpful even though many other people have faced similar problems.
2. the "res/game_music.ogg" is in the right place. I am new here and can't include pictures in my question otherwise I would include a screenshot to show that the file is in right place.
Important note:
I faced some confusions when setting up the project. I don't want to lengthen my question now so I'm not talking about that now. But if anyone here tells me that my problem here is related to lwjgl.jar/slick.jar/native files etc. then I will include it.
At this moment just know that before trying to load music, every other render/update thing worked fine.
Would appreciate any helpful answer.
You have to include 2 jars in your project.
Download the Slick2D archive, and then add lib/jogg-0.0.7.jar and lib/jorbis-0.0.15.jar to your project.
Hope it helps.

Fetched from upstream eclipse github: java.lang.ClassNotFoundException

I'm trying to revert to a previous commit. I'm using Juno eclipse and github/egit.
Reverting works: I can see my old code. But when I try to run it, I get this:
java.lang.NoClassDefFoundError: mmPackage/Main
Caused by: java.lang.ClassNotFoundException: mmPackage.Main
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Exception in thread "main"
My package is called mmPackage.
This exact code worked for me when I pushed it to github a few days ago. Now that I've revered to a previous commit, it just can't seem to find my class with a main method!
I have tried:
Building project
Making sure my src folder is in the build path
I also noticed my bin folder does not seem to contain any .class files. I tried deleting it using the file system browser and re-running, but no luck. And now I can't even see a bin folder in my file system!
Thank you!

java.lang.NoClassDefFoundError while running JUnit

Hi i am getting this error please help me out, thanks
java.lang.NoClassDefFoundError: com/ge/energy/wp/core/exception/WPException
at java.lang.Class.getDeclaredMethods0(Native Method)
at java.lang.Class`enter code here`.privateGetDeclaredMethods(Unknown Source)
at java.lang.Class.getMethod0(Unknown Source)
at java.lang.Class.getMethod(Unknown Source)
at org.junit.internal.requests.ClassRequest.hasSuiteMethod(ClassRequest.java:62)
at org.junit.internal.requests.ClassRequest.getRunnerClass(ClassRequest.java:50)
at org.junit.internal.requests.ClassRequest.getRunner(ClassRequest.java:28)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.<init>(JUnit4TestReference.java:28)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestClassReference.<init>(JUnit4TestClassReference.java:24)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.createTest(JUnit4TestLoader.java:40)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestLoader.loadTests(JUnit4TestLoader.java:30)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:445)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:673)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:386)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:196)
Caused by: java.lang.ClassNotFoundException: com.ge.energy.wp.core.exception.WPException
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClassInternal(Unknown Source)
... 15 more
try adding source folder to your classpath. If you use eclipse, right click test file and select Run configuration under Junit test and select classpath and add your source folders to class path.
Check class WPException. Usually your IDE should show you if something is wrong with the java file but not with the class file - either it wasn't compiled or missing (the error is triggered when the JVM can't find the class) for some other reason, one of them could be, like bluelabel mentioned, a problem with the PATH.
I know this is old post...but may help someone else...
whenever I have faced this issue only problem have been the java version eclipse is defaulted to - which is the eclipse jre.
Fix - change to the proper jre installed on your machine !

Jar cannot be opened on different Computer ("Can not find main class")

Today I programmed myself a Little game, which I compiled into a jar through Eclipse - I made sure its a executable jar, or runnable jar or however you want to call it.
I've sent the jar to a friend of mine, but oddly he's not able to open it.
He's always receiving the "Can not find main class" error, which shouldn't pop up since it works perfectly for me. I've already googled but was not able to find a answer.
If you're interested, you can take a look here, if it works for you:
http://www.file-upload.net/download-3939961/WidzDeluxe.jar.html
Now the question I have is kind of obvious I guess, is the error only for him or do you all have the same problem? What's the cause of it?
If people wish, I also upload the code.
You have compiled class files bundled inside this jar with a different (higher) version of Java. Presumably it was Java 1.7 and the friend of yours is trying to open it with Java 1.6.
Here is the stacktrace I received trying to open your executable jar with Java 1.6.0_21:
Exception in thread "main" java.lang.UnsupportedClassVersionError: NewJFrame : Unsupported major.min
or version 51.0
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClassCond(Unknown Source)
at java.lang.ClassLoader.defineClass(Unknown Source)
at java.security.SecureClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.defineClass(Unknown Source)
at java.net.URLClassLoader.access$000(Unknown Source)
at java.net.URLClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
Could not find the main class: NewJFrame. Program will exit.
One possible solution that came to my ming would be to set the compliance level to let's say 6.0 in Java Compiler settings in Eclipse. That should to the trick.
I had this same problem, found I was compiling the program for Java 1.7. I ended up updating Java on all my computers that I was running it on and it worked great.