aspose file tools*
The moose likes Game Development and the fly likes run game from command line, from a working game project in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Game Development
Bookmark "run game from command line, from a working game project in Eclipse" Watch "run game from command line, from a working game project in Eclipse" New topic
Author

run game from command line, from a working game project in Eclipse

Andrew Pidcock
Greenhorn

Joined: Dec 13, 2010
Posts: 5
Could anyone help me to transform an Eclipse run configuration into a Java command-line?

I have a project in Eclipse involving jars and DLLs that runs fine and has done for months, but I now want to run it from the command line and I can't find how to translate all the run configurations into command line parameters properly
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
What do you want to run? A jar? Or just the file?

What kinds of things are in eclipse's configuration? Can't you just set the classpath, compile, and run?
Andrew Pidcock
Greenhorn

Joined: Dec 13, 2010
Posts: 5
I do not mind if it's packages as a jar or if it's loose files - I just want it to run

stuff in the project: well there are DLLs, jars, a whole bunch of things - it's openGL and openAL

I've tried setting the classpath to various directories, but it can't run.. it wants its various jars and things
Kevin Workman
Ranch Hand

Joined: Sep 28, 2010
Posts: 151
Andrew Pidcock wrote:I do not mind if it's packages as a jar or if it's loose files - I just want it to run

stuff in the project: well there are DLLs, jars, a whole bunch of things - it's openGL and openAL

I've tried setting the classpath to various directories, but it can't run.. it wants its various jars and things


You could just export the whole thing as a runnable jar.

But if "it wants its various jars and things", then you have to make sure that they're all on the classpath. You can't just set it to "various directories" and hope for the best.
Andrew Pidcock
Greenhorn

Joined: Dec 13, 2010
Posts: 5
Eclipse has a "export to runnable jar" and I have tried that, but when I try to run it, nothing happens and I see no error messages

I suspect it is that it cannot find the jars and DLLs - can you tell me how to see error messages from running a runnable jar? That would be a place to start
Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
Instead of exporting to a "runnable jar" try exporting to a regular jar. The last page of the export wizard will give you an option to specify the class with the "main()" function. If you specify this, it will work both as a file that you can click on (in windows) or run from the command line via:

java -jar yourfilename.jar

It should give you any needed error messages, for example, if it can't locate a class because it was not included in the export.

Also, the export to jar wizard is not the easiest--lot's of gotchas in it, imho. On the page where you select the classes to export, make sure that you expand out all of the tree, and click on each package to ensure that all the classes you want to export are marked for export. It's really easy to mistakenly just export a single class or package from a larger project.

You can also copy the jar into a name with a .zip extension and examine the contents that way to see if all the libraries are there or not.

If this doesn't help, also consider the Eclipse 'newbies' forum. They've been tremendous in helping me in the past.

Good luck!
Andrew Pidcock
Greenhorn

Joined: Dec 13, 2010
Posts: 5
Thanks mate

The other day, blind and deaf, I just tried a few things and got it to work.. I do not know how

I asked Eclipse to make me a runnable jar, and I dumped all the DLLs and JARs into the same dir as the jar, and the /sounds and /images dirs as well, and it ran

So I can now deliver =)
Phil Freihofner
Ranch Hand

Joined: Sep 01, 2010
Posts: 115
    
    1
If it works, it works! That's great.

The next level will be when you figure out how to get ALL the resources to fit into a single, clickable jar. Not a trivial task, but not insurmountable either. I've done this with image and sound files but never had a call to also pack dlls.
Andrew Pidcock
Greenhorn

Joined: Dec 13, 2010
Posts: 5
indeed yes, but I am at the point now where I can share with my friends

If the NSI installer won't work with this setup THEN comes the next step
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: run game from command line, from a working game project in Eclipse