13.07.2015 Views

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

Java™ Application Development on Linux - Dator

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

34Chapter 2An Embarrassment of Riches: Editors2.2EYE TO EYE WITH VIJava programs c<strong>on</strong>sist of Java classes. Java classes are text files with Java statementsand expressi<strong>on</strong>s. In order to write a Java program, then, you need to beable to enter text into a file. Sounds simple enough.With <strong>Linux</strong> and its GNU tools, you have an amazing array of choices forhow to do this. Some are GUI tools not unlike simple word processors. Others,like vi and Emacs, predate GUI tools, but provide much the same capabilitywithout the luxury (or annoyance) of a mouse or menus. 1The editor named vi (pr<strong>on</strong>ounced as you would spell it: “vee-eye”) is <strong>on</strong>eof the most enduring tools in <strong>Linux</strong>. Its popularity comes from a combinati<strong>on</strong>of power and ubiquity—you can find it <strong>on</strong> virtually every release of UNIX and<strong>Linux</strong> since 1985. But it is a powerful editor that can do a lot with <strong>on</strong>ly a fewkeystrokes.There are actually several variants of vi from which to choose. Each issome<strong>on</strong>e’s attempt to go <strong>on</strong>e better <strong>on</strong> vi, but all retain the same basic syntaxand what you learn here will work equally well <strong>on</strong> any of the vi cl<strong>on</strong>es. You canchoose am<strong>on</strong>g• elvis• nvi• vimStart up vi by typing the command name at a shell prompt, followed bythe name of the file(s) that you want to edit:$ vi Account.javaKeep in mind that vi was developed in the days of character-<strong>on</strong>ly videoscreens. Keyboards didn’t always have arrow keys or other special characters,which have since been (largely) standardized by the advent of the IBM PC. Inthat situati<strong>on</strong>, the authors of vi had <strong>on</strong>ly the alphabetic characters to use for all1. We realize that vi is famous for being difficult to learn and n<strong>on</strong>intuitive. The UI design ofvi dates back to earliest cursor-addressable display terminals. User interface design has come al<strong>on</strong>g way since then. The vi UI does indeed show its age. But the program refuses to die. Why?Because while simple GUI editors make the easy stuff easy, vi makes the hard stuff easy. Youcan fall back <strong>on</strong> pico or kate or other GUI editors if you want, but bear with us. Mastering vireally does pay off.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!