Exec jar with netbean

i got a little problem… but before i explain it i have to tell that i did a search on the forum… on google… and about everywhere i can think of and found some thing that can solve my problem but they're were beyong my understanding so that why i'm asking here… and too here because i don't want to ressurect a threat old from 2006 so here it goes…

i did some project at school with jme… some ufo chasing cows… and now i'd like to dist it… i did the getting started part where it say how to make your project redistribuable but got no luck. i mean the project run fine with netbean but when redist… it say "Could not find main-class main in "path/jinput.jar" and all is where it should be like my game.jar with lib/jme's jar and all my textures and model are in the game.jar… i did incorporate all in my project… and i also checked inside the jar to see if they were there… btw i use netbean 6 and used netbean5.5 and in my opinions they almost the same…

now i'm kind of running out of solution and of luck and patience… and everything… i know this has already been posted somewhere but like i said i did not understand how he solved it…

thank in advance for you time…

if you like any info feel free to ask i'll be around all day…

I think there should be a manifest.mf file in the game.jar under META-INF

(the jar You try to start with java -jar game.jar)

and in this file the main class and classpath should be specified.

Note that You can't put the native libs (.dll .so …) into the jar afaik so You still have to dist them in a seperate directory and set a -Djava.library.path=??? to it.

edit: You can set the main class of Your project in the properties dialog of the project under run btw.

if i try to load the jar using java -jar game.jar -djava.library.path=f:/jme/lib

it give me an unsatisfiedlinkerror: no lwjgl in java.library.path but the path i give is the one where the dll and jar and etc… of jme are…

like f:/jme/lib

also in my manifest there is a class-path and main-class and there are both specified

and the main class is also specified in the run dialog

if you want to start your game from the command line, you need to set  the classpath with -cp and as you did the library path for the native libraries.

In the classpath you list every jar which is needed by our project, like jme.jar, jme-model.jar etc.

The library path points to the directory which contains your native libraries.

The last argument is the full classname (with package name) which contains the main() method

its explained in the Wiki getting started guide

this is an example to run a test which uses relative paths:

java -Djava.library.path=./lib -cp ./lib/lwjgl.jar;./lib/jogg-0.0.7.jar;./lib/jorbis-0.0.15.jar;./target/jme.jar;./target/jme-awt.jar;./target/jme-effects.jar;./target/jme-model.jar;./target/jme-audio.jar;./target/jme-terrain.jar;./target/jmetest.jar;./target/jmetest-data-model.jar;./target/jmetest-data-images.jar;./target/jmetest-data-skybox1.jar;./target/jmetest-data-sound.jar;./target/jmetest-data-texture.jar jmetest.effects.TestDynamicSmoker

btw: if you use java 6 you can use -cp ./target/* instead of listing every single jar
Grelot said:

"Could not find main-class main in "path/jinput.jar"

This seems to indicate that you have a space in your command line, something like:

java -classpath /my path/jimput.jar

And what java is trying to do is use /my as your classpath, and from there find the path/jinput.jar file (and failing, obviously)

i did remove the space in my project to try and still having the problem…


:Edit: what i'd like to do is start it from web start but it always do the "could not find main-class main in file:/f:/game/lib/jinput.jar

Could you post your JNLP file?

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="file:/F:/yan/UFOTime/dist/" href="launch.jnlp">
        <description kind="short">Ufo_Time</description>
        <homepage href=""/>
        <j2se version="1.6+" java-vm-args="-Djava.library.path="F:yanjmejmelib""/>
        <jar href="UFOTime.jar" main="true" download="eager"/>
        <jar href="lib/jinput.jar" download="eager"/>
        <jar href="lib/jme-audio.jar" download="eager"/>
        <jar href="lib/jme-awt.jar" download="eager"/>
        <jar href="lib/jme-collada.jar" download="eager"/>
        <jar href="lib/jme-editors.jar" download="eager"/>
        <jar href="lib/jme-effects.jar" download="eager"/>
        <jar href="lib/jme-font.jar" download="eager"/>
        <jar href="lib/jme-gamestates.jar" download="eager"/>
        <jar href="lib/jme-model.jar" download="eager"/>
        <jar href="lib/jme-scene.jar" download="eager"/>
        <jar href="lib/jme-terrain.jar" download="eager"/>
        <jar href="lib/jme-xml.jar" download="eager"/>
        <jar href="lib/jme.jar" download="eager"/>
        <jar href="lib/jogg-0.0.7.jar" download="eager"/>
        <jar href="lib/jorbis-0.0.15.jar" download="eager"/>
        <jar href="lib/junit-4.1.jar" download="eager"/>
        <jar href="lib/lwjgl_util_applet.jar" download="eager"/>
        <extension name="jnlpcomponent1" href="jnlpcomponent1.jnlp"/>
    <application-desc main-class="main">

here's the jnlp
Grelot said:
<application-desc main-class="main">

you need to give it the full class name, including the package name.

for example: com.grelot.startup.MyMainClass

Unless your class containing the main method is in the default package, but thats unlikely i think.
Is your class which contains the main method really called 'main', or is the main method inside another class?

Besides, you should change you back slashes to forward slashes… you are using URLs, not windows native paths here.

On the same line, you should use file:/// instead of file:/ as your protocol.