Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (593)
Games in Android Showcase (168)
games submitted by our members
Games in WIP (646)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How to package my Text Game  (Read 2374 times)
0 Members and 1 Guest are viewing this topic.
Offline colossus

Junior Newbie

« Posted 2012-03-01 21:17:34 »

I developed a text adventure game played in the console for an english project. I need to export it to a jar or an exe so a layman like my teacher can play it. I tried exporting it and it either does nothing or throws up an error warning that says "Could not find main class GameStarter.class" Can you guys help me out?
Offline StonePickaxes

JGO Coder

Medals: 5
Projects: 2

Nathan Kramber

« Reply #1 - Posted 2012-03-01 23:31:59 »

If you are using eclipse, you need to export it as a runnable jar. File --> Export

However, simply double clicking this jar won't open it since it's supposed to be in the command prompt. You need to open notepad and write this line of code in there:

java -jar "JAR NAME HERE".jar

Save that as "Play.bat" Make sure it is a batch file!

Then just put it into a zip or rar archive, and send it to him. Tell him to run the batch file to play the game. (note the .bat and .jar files have to be in the exact same directory)

Hope this helps.

Check out my website!
Offline colossus

Junior Newbie

« Reply #2 - Posted 2012-03-02 20:09:35 »

Thanks! This is exactly the kind of answer I needed.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline StonePickaxes

JGO Coder

Medals: 5
Projects: 2

Nathan Kramber

« Reply #3 - Posted 2012-03-02 20:51:17 »

No problem  Cool

Check out my website!
Offline _Al3x

Senior Devvie

Medals: 7

Indie Games FTW!

« Reply #4 - Posted 2012-03-03 19:49:55 »

Thank you both, you have answered an old question I had for some time now.

Cheers! Smiley


Well, I have some doubts left:

What happens when exporting a large project with many resources, like 20 classes (20 .class files), textures, libraries... It all comes to ONE .jar? And that's the "game"? Double clicking it runs it? (not a text game like OP)

Offline UprightPath
« Reply #5 - Posted 2012-03-03 20:07:53 »

If it's more complicated, but not using .dll style libraries, then yes that's all.

I've got several projects that are LOTS of classes. By that, I think it's... 50-60 classes? Perhaps more. I'm not sure off the top of my head, and it works through one jar. Only issues are making sure that people remember to pick up the outside config classes and the like.

Only when you're using native libraries, or libraries with license separate packaging requirements, will you have to do it another way. There are other situations where it might be best to do it another way as well. As I understand it, linux likes to treat .jars differently, certain installed software will cause it as well (Since in essence, a .jar is just a packaging/compression file like a .zip, .rar, .7zip, etc).

Offline StonePickaxes

JGO Coder

Medals: 5
Projects: 2

Nathan Kramber

« Reply #6 - Posted 2012-03-03 20:29:09 »

To calm your doubts of using many classes in one jar, Minecraft uses HUNDREDS of classes, and it is only one main jar, plus the external libraries and stuff.  Grin


Check out my website!
Offline _Al3x

Senior Devvie

Medals: 7

Indie Games FTW!

« Reply #7 - Posted 2012-03-03 21:55:04 »

Sure, I know that Wink
What I don't, it's relative to the topic, how to wrap all those things together and make a poolish distribution version of the game, maybe an installer? maybe a stand alone?

Thanks for your reply Smiley

Offline sproingie

JGO Kernel

Medals: 202

« Reply #8 - Posted 2012-03-03 22:28:51 »

Minecraft is tiny.  I regularly package enterprise apps that use Spring and such into one jar, and it adds up to thousands of classes.  If this ever threatens to get slow, the jar format supports an index file to speed things up.  You are never going to overstuff a jar in any normal use.

There are a lot of single jar packers, including JarSplice, written by our own Kappa.  My personal favorite is One-JAR, which uses nested jars (makes it easy to add and remove entire jars using the 'jar' command alone) and has its own simple solution to the native libs problem of using a binlib/ directory you just drop things into.  It also integrates nicely into ant, maven, and sbt builds.
Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

deepthought (31 views)
2015-06-30 15:39:44

deepthought (34 views)
2015-06-30 15:39:09

deepthought (45 views)
2015-06-30 15:36:52

Za\'Anzabar (21 views)
2015-06-29 05:44:54

TritonDreyja (36 views)
2015-06-24 17:10:40

CopyableCougar4 (35 views)
2015-06-23 00:34:45

BurntPizza (39 views)
2015-06-21 20:36:46

cookiecompiler (82 views)
2015-06-11 15:42:53

cookiecompiler (45 views)
2015-06-11 15:41:14

NegativeZero (75 views)
2015-06-11 09:49:18
How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30

Intersection Methods
by Roquen
2015-05-29 08:19:33

List of Learning Resources
by SilverTiger
2015-05-05 10:20:32

How to: JGO Wiki
by Mac70
2015-02-17 20:56:16

2D Dynamic Lighting
by ThePixelPony
2015-01-01 20:25:42

How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!