Joppe De Cuyper
Joppe De Cuyper

Reputation: 414

Java Console In Eclipse, But What If Using As Jar?

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

Upvotes: 0

Views: 742

Answers (3)

Tony R
Tony R

Reputation: 11524

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.

Upvotes: 1

Dave
Dave

Reputation: 4597

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

Upvotes: 1

paulsm4
paulsm4

Reputation: 121799

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:

Upvotes: 2

Related Questions