Courses‎ > ‎AP Computer Science‎ > ‎Konstantinovich‎ > ‎


posted Jan 3, 2019, 6:16 AM by Konstantinovich Samuel   [ updated Jan 4, 2019, 5:48 AM ]
Goal: Terminal Manipulation

Download the java file, and the jar file.

A jar file like this is a library that can be used, but you need to compile in a particular manner that uses the -cp flag. ***

Assuming you are in a directory with the java file AND the jar file:

$ javac -cp lanterna.jar:.
$ java -cp lanterna.jar:. TerminalDemo

1)  -cp (which stands for classpath) includes the jar file, a separator colon, and . (current directory)
2) "." which is almost always required because it means to include classes in the current directory, which is required if you have more than one class in your prioject.
3) You can also have multiple jar files, in different locations if you like:
-cp  ../file.jar:file2.jar:.

If your terminal pops up a terminal and lags:

You are on a system with a windowing environment. We can fix that!
You can pass the following option to the JRE:
$ java -Djava.awt.headless=true -cp lanterna.jar:. TerminalDemo


TerminalFacade.createTextTerminal(); //USE THIS COMMAND INSTEAD!

***I will ONLY compile on the terminal, so don't use eclipse until the last day and then realize you have no idea how to compile it on the terminal 

When you run this, some terminals will pop up a second terminal and then lag, this is unfortunate, but can easily be fixed. (There is probably a better way but it doesn't matter)

Konstantinovich Samuel,
Jan 4, 2019, 6:25 AM
Konstantinovich Samuel,
Jan 3, 2019, 6:16 AM