Make a text game in an executable jar - Java

I'm just wondering how you could make a text console game in an executable jar.

From what I saw on the rest of this site, I will need to use JTextField and JTextPane. I also know that to launch it he will have to create his own console. I don’t care how difficult it is if it is simple enough to understand. If that were the case, a way to move forward could you point me in the right direction to find out how to do this.

If this is a duplicate of the question elsewhere, just point me in the direction; I searched and cannot find simple questions.

+4
source share
3 answers

, , .

:

  • 1 . ()
  • , PrintStream. PrintStream, JTextPane. InputStream (System.in). System.setIn(InputStream) System.setOut(PrintStream). , .

# 2: @Jordan.McBride System JRE. JRE System, . PrintStream , . , System.out. , JRE InputStream , System.in. Java Stream, System.setIn(..) System.setOut(..). GUI-, , .

, PrintStream InputStream, , , . API PrintStream . println() print() write(). print println. - ,

public void println(String outstr)
{
  this.textBox.setText(this.textBox.getText() + outStr + "\n");
}

, textBox, , .

+1

JTextField JTextPane, .

manifest.txt. .

Main-Class: MyMainClass

javac MyMainClass.java SomeOtherClass.java
jar -cvfm my-game.jar manifest.txt *.class

, ,

java -jar my-game.jar
+1

, ACM Java Task Force ConsoleProgram. .

http://www-cs-faculty.stanford.edu/~eroberts/jtf/

0
source

Source: https://habr.com/ru/post/1523753/


All Articles