0

So,

I have made a little game in eclipse, it generates a rondom number from 1 - 1000 , when playing out of Eclipse, it plays in the eclipse console, but what if i want to play it without eclipse? There is no console showing up? Anyone a idea on how to fix this? EDIT : I would like a new GUI instead of CMD.

Grts PS: Tell me if you need a specific part of the source code

Joppe De Cuyper
  • 394
  • 1
  • 6
  • 17

3 Answers3

2

1) You should probably export your program as a .jar file.

This isn't absolutely necessary - but it's better. And it sounds like you've already done it :)

2) Be sure to specify the main class in Eclipse before you export the .jar

3) Once you have the .jar, you can:

   a) execute "java -jar myjar.jar" from a command prompt (for a console-mode program)    
   b) execute "javaw2 -jar myjar.jar" from a command prompt (for a Swing/GUI program)

4) You can also set a "file association" with javaw in Windows so that you can just double-click on the .jar to execute it:

Community
  • 1
  • 1
paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • You want a GUI, that's what "javaw" is for. You don't want to type "javaw" in a command prompt, that's what a file association is for. Or, for that matter, a .bat file and/or desktop shortcut are other options. You want it, you got it ;) Simple as that :) – paulsm4 Aug 18 '12 at 16:57
1

If you want a GUI, you will have to develop one yourself. There is no "Java Console GUI" that I've ever heard of.

Dave
  • 4,546
  • 2
  • 38
  • 59
1

It seems the OP wants to reroute console output to a location of his choosing, not open an actual shell.

Here is one way to reroute stdout.

You can send it to a string, stream, file, etc. and then print it yourself into a window.

Tony R
  • 11,224
  • 23
  • 76
  • 101