Need Help Please. Problem with JAR

Hello,



I tried to create a jar from eclipse. The jar was created but it failed to run. The debug txt file was created showing the following:



1 July 2007 4:07:49 pm com.jme.app.BaseGame start

INFO: Application started.

1 July 2007 4:07:49 pm com.jme.system.PropertiesIO <init>

INFO: PropertiesIO created

1 July 2007 4:07:49 pm com.jme.system.PropertiesIO load

WARNING: Could not load properties. Creating a new one.

1 July 2007 4:07:49 pm com.jme.app.BaseGame start

INFO: Application ending.



What seems to be the problem ? Why is not running ?



Thanks!

that's not enough information for a proper diagnosis.

try adding some logging to your app  and setting a higher logging level :expressionless:

haristhe said:

I tried to create a jar from eclipse. The jar was created but it failed to run. The debug txt file was created showing the following:


Does it link to the JME and JOGL files in the classpath section of the manifest file?

Well i added logging to my app (Level.Finest). The output was still the same ! If the problem is that it fails to load the properties what can i do ? How can i solve it ?

If it makes any difference, i choosed through the Jar Export (eclipse), only export all output folders for checked projects.



Thanks !

did you start the jar from the console?

No.I just double-clicked it. How can i launch it through the console ? (console meaning cmd ? )

yes, cmd for console on windows



I suggest you manually create jar file. If you can run your app from eclipse you can run it from console, if you can run it from console you can create a jar :wink: … read tutorial about creating a jar from console.



edit: oh yeah, run a jar file with "java -jar name.jar", see if you get any exceptions

I started from the console. The following where shown :



10 July 2007 8:57:38 μμ com.jme.app.BaseGame start

INFO: Application started.

10 July 2007 8:57:38 μμ com.jme.system.PropertiesIO <init>

INFO: PropertiesIO created

10 July 2007 8:57:38 μμ com.jme.system.PropertiesIO load

WARNING: Could not load properties. Creating a new one.



java.lang.NoClassDefFoundError: org/lwjgl/LWJGLException

        at com.jme.app.AbstractGame.getAttributes(AbstractGame.java:191)

        at com.jme.app.BaseGame.start(BaseGame.java:49)

        at testPackage.MyGame.main(MyGame.java:208)



10 July 2007 8:57:38 ΉΉ com.jme.app.BaseGame start

10 July 2007 8:57:38 μμ com.jme.app.BaseGame start

INFO: Application ending.



Any suggestions now ?



Thanks a lot!

Add the lwjgl.jar to your classpath.

If you mean lwjgl.jar in the lib, I have. To be sure i added almost everything.

no, you just think you did.



please read this section of the wiki on how to start a jme application.

i also suggest that you read about starting java apps in general and about the java jvm command line arguments.

I will have a look at those.Thanks.



I did not create the jar manually. I did it through eclipse. I just choosed everything in the Jar File Specification. The problem is, why it was not included it (the lwjgl.jar) as it was supposed to?




there is no way you can pack everything in a single jar, at least not that I'm aware of. Native libs are needed, so you must supply them as jvm argument.



in short, this is how I do it, I create a jar file with a manifest file:

"manifest.":

Main-Class: viktorije.Viktorije
Class-Path: lib/jme.jar
  lib/jme-terrain.jar
  lib/jme-awt.jar
  lib/jme-model.jar
  lib/lwjgl.jar
  lib/lwjgl_util.jar
  lib/jinput.jar


do not forget to put <enter> at the end as it is required by jar standard

jar -cfvm viktorije.jar manifest "viktorije"
where viktorije is package (dir) with my .class files

and then I run it with:
java -Djava.library.path=natives -jar viktorije.jar
where natives is dir where... well you guess it, I keep native files

you could try the fatjar eclipse plugin. i don’t use it myself, but i heard it does a good job.

you can download the current version (0.0.25) form the sf.net project site.

make sure you check the FAQ and eventually the tutorial.

Well i downloaded fatjar and used it. I believe some progress has been made. I created a jar file with fatjar and a new error occurred, the following :



12 July 2007 3:06:35 ΉΉ com.jme.app.BaseGame start

INFO: Application started.

12 July 2007 3:06:35 ΉΉ com.jme.system.PropertiesIO <init>

INFO: PropertiesIO created

12 July 2007 3:06:35 ΉΉ com.jme.system.PropertiesIO load

INFO: Read properties

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:75)

        at java.security.AccessController.doPrivileged(Native Method)

        at org.lwjgl.Sys.doLoadLibrary(Sys.java:68)

        at org.lwjgl.Sys.loadLibrary(Sys.java:84)

        at org.lwjgl.Sys.<clinit>(Sys.java:101)

        at org.lwjgl.opengl.Display.<clinit>(Display.java:108)

        at com.jme.system.lwjgl.LWJGLPropertiesDialog.<init>(LWJGLPropertiesDial

og.java:148)

        at com.jme.app.AbstractGame.getAttributes(AbstractGame.java:191)

        at com.jme.app.BaseGame.start(BaseGame.java:60)

        at jmetest.TutorialGuide.HelloSimpleGame.main(HelloSimpleGame.java:78)

12 July 2007 3:06:35 ΉΉ jmetest.TutorialGuide.HelloSimpleGame cleanup

INFO: Cleaning up resources.

12 July 2007 3:06:35 ΉΉ com.jme.app.BaseGame start

INFO: Application ending.



Why there is no link between lwjgl and java library path ? How can i solve this ?



Many thanks in advance !

you obviously didn't read the FAQ :frowning:

sfera said:

please read this section of the wiki on how to start a jme application.
i also suggest that you read about starting java apps in general and about the java jvm command line arguments.

Sorry if just quoting this doesn't seem helpful, but it doesn't look like you have paid much attention to the suggestion about reading up on how to start java apps, and that's quite essential when working with jME (or rather, native libs and java in general)!
Just relying on fatjar to magically fix everything for you won't do here. You still have to "tell" java where to find the required native libraries, so you'll have to use some kind of start script, which starts java as described above:
Kova said:

and then I run it with:
java -Djava.library.path=natives -jar viktorije.jar
where natives is dir where... well you guess it, I keep native files

Well i finally managed to run my jar file. I should have listened to all of you from the beginning. Sorry for being lazy and impatient. But i have one more question. OK, i can run my jar file through the console, but i have to specify which directories to look for ( Djava.library.path…). How can i make a single file where these directories are already defined and with just a double click the application would know where to look for and start running rather than running the console and defining the directories ?

it’s not that simple to create a file you can just double click (unless you want to limit yourself to a single operating system).



you might want to look (again) into the wiki. there is a section called Deployment Choices. take a look at the launchers section.

or maybe:

http://www.google.com/search?hl=en&q=unix+shell+scripting&btnG=Search

http://www.google.com/search?hl=en&q=windows+batch+scripting&btnG=Search