Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
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 2201 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: 4
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.
-Nathan

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: 4
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

Edit:

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: 4
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

-Nathan

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.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (29 views)
2014-11-22 12:13:56

xFryIx (71 views)
2014-11-13 12:34:49

digdugdiggy (50 views)
2014-11-12 21:11:50

digdugdiggy (44 views)
2014-11-12 21:10:15

digdugdiggy (38 views)
2014-11-12 21:09:33

kovacsa (62 views)
2014-11-07 19:57:14

TehJavaDev (67 views)
2014-11-03 22:04:50

BurntPizza (64 views)
2014-11-03 18:54:52

moogie (80 views)
2014-11-03 06:22:04

CopyableCougar4 (80 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!