Problem with packaging

Started by strollingchimp, September 29, 2011, 21:00:33

Previous topic - Next topic

strollingchimp

First of all, sorry if this is in the wrong place, I'm a noob.

I am using slick-util and lwjgl to write this game.

I am having a problem with making a runnable jar from Eclipse. The jar seems to package fine and it appears on my desktop. I told Eclipse to package the required libraries into the output jar. However when I go to run the jar it does not run. No error it just doesn't run. So, I decide to run it through cmd but it still does not work. This is the output that I get:

Exception in thread "main" java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
Caused by: java.lang.UnsatisfiedLinkError: no lwjgl in java.library.path
        at java.lang.ClassLoader.loadLibrary(Unknown Source)
        at java.lang.Runtime.loadLibrary0(Unknown Source)
        at java.lang.System.loadLibrary(Unknown Source)
        at org.lwjgl.Sys$1.run(Sys.java:73)
        at java.security.AccessController.doPrivileged(Native Method)
        at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
        at org.lwjgl.Sys.loadLibrary(Sys.java:82)
        at org.lwjgl.Sys.<clinit>(Sys.java:99)
        at org.lwjgl.opengl.Display.<clinit>(Display.java:130)
        at platformertrylwjgl.PlatformerTry.startGame(PlatformerTry.java:37)
        at platformertrylwjgl.PlatformerTry.main(PlatformerTry.java:170)
        ... 5 more

Can somebody please help, I am a noob and I do not know what to do.

kappa

hmm, I'd go with something a little more simple, like the JarSplice tool found here.

See this link for some quick instructions on how to use it.

strollingchimp

I am having a few problems with that too. Whenever I try to run the jar that jarsplicer compiles I get an error "Invalid or corrupt jar file". Did I add the main class right?

kappa

that error usually means that the fat jar failed on creation. Likely you're doing one of the steps wrong, try running jarsplice from the cmd/console "java -jar jarsplice-*.jar" it should give you an exception on why its failing to create the jar.

jediTofu

Java Web Start is good too.  Check out the wiki for that.  You could also do a bash shell script file for linux/macosx and a batch file for windows.
The shell script would be like this (assuming the lwjgl directory is in the current directory):

RunMe.sh
#!/bin/sh
java -Djava.library.path=./lwjgl/native/linux -cp .:lwjgl/jars/lwjgl.jar:lwjgl/jars/lwjgl_util.jar:lwjgl/jars/jinput.jar:myjar.jar  MyGame


Batch would be the same, except ";" instead of ":", "native/windows", no "#!/bin/sh", and renamed to RunMe.bat.
cool story, bro

strollingchimp

I tried running jarsplice from cmd and the message I got was this

java.util.zip.ZipException: duplicate entry: liblwjgl.so
        at java.util.zip.ZipOutputStream.putNextEntry(Unknown Source)
        at java.util.jar.JarOutputStream.putNextEntry(Unknown Source)
        at org.ninjacave.jarsplice.core.Splicer.addNativesToJar(Splicer.java:141
)
        at org.ninjacave.jarsplice.core.Splicer.createMacApp(Splicer.java:64)
        at org.ninjacave.jarsplice.gui.CreatePanel.actionPerformed(CreatePanel.j
ava:117)
        at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
        at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
        at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
        at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Sour
ce)
        at java.awt.Component.processMouseEvent(Unknown Source)
        at javax.swing.JComponent.processMouseEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
        at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Window.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
        at java.awt.EventQueue.access$000(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.awt.EventQueue$3.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.awt.EventQueue$4.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Sour
ce)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
        at java.awt.EventDispatchThread.run(Unknown Source)
File Saved as C:\Users\Matt\Desktop\game.jar

Does that mean anything to you?

kappa

Quote from: strollingchimp on October 01, 2011, 08:06:02
I tried running jarsplice from cmd and the message I got was this

java.util.zip.ZipException: duplicate entry: liblwjgl.so
        at java.util.zip.ZipOutputStream.putNextEntry(Unknown Source)
        at java.util.jar.JarOutputStream.putNextEntry(Unknown Source)
        at org.ninjacave.jarsplice.core.Splicer.addNativesToJar(Splicer.java:141
)
...

Does that mean anything to you?
Yes it basically means that you are trying to add the file liblwjgl.so twice to the zip, which is why its failing. Check the natives tab to ensure that file is only added there once, secondly check that jars tab and make sure that the file isn't in any of the jars you add there (especially as slick has that in linux-natives.jar, so just be sure you are not adding the native jars to that tab).

strollingchimp

So that has solved one problem, but whenever I run from CMD I get "Could not find or load main class PlatformerTry."

I don't really know where to find the name of the main class. I just used the project name.

Just to clear things up, I am not the person who coded this game. A friend did, I am a Java noob.

kappa

yeh, entering the name of the project is wrong and won't work.

You have to find out which is the main class in the project and enter that exactly (its case sensitive) and you also have to prepend it with any package names that it may be in.

You'll need the above information whatever method you use, otherwise the JVM will not know which class to run from.

strollingchimp

I'm guessing it is the name of the thing in the src folder in eclipse. Which in my case is platformertrylwjgl. I think the package names are platformertrylwjgl.graphics etc. Am I right?

kappa

if 'platformertrylwjgl' is the name of the main class (i.e. the class that you click in eclipse to run the game) and the package name is 'platformertrylwjgl.graphics' (will be the first line of code in the main class file). Then the name of the main class that you need to enter is 'platformertrylwjgl.graphics.platformertrylwjgl' (without quotes).

strollingchimp

Okay, now I think I understand. Just one last question, in the main file that I run from there is code that says public class PlatformerTry, would that be the main class?

kappa

Yes.

Do keep in mind that class names are case sensitive so 'platformertrylwjgl.graphics.PlatformerTry'.

strollingchimp

Also, as I have multiple packages do I need to enter platformertrylwjgl.graphics.platformertrylwjgl.entity or do I need to enter platformertrylwjgl.graphics.entity?

kappa

doesn't matter about multiple packages, in this case you only need the package which the main class is inside.
also consider joining the LWJGL IRC Channel, should be a better medium if you have lots of quick and small questions.