December 17, 2011

Java on Linux - Writing Programs

This page provides the basics of using java to write programs on a linux system. If you need to install java, you should go back to my discussion of java on linux, decide what java flavor you want to install, and follow the steps to install it.

First, make sure that you have the java compiler installed by typing javac -version. This should show the version and brand of the java you have installed.

You can do Java development in any number of ways. Some people want an IDE like eclipse, and if that is you, more power to you, and you may as well stop reading now. I just use my favorite editor and command line tools.

The first thing you do is to use your favorite editor to produce HelloWorldApp.java (or copy it from some place on the web). Then you compile it via:

javac HelloWorldApp.java 
This will produce HelloWorldApp.class - which you run by typing:
java HelloWorldApp
 Hello World!
Notice that you do not type the .class extent when running the program, but you do type .java when compiling. This is called non-orthogonality. You get used to it.

Once you have pulled this off, the java world lies at your fingertips and you can grab whatever java book you wasted money on and dive in.

Good Luck and Best Wishes!


Have any comments? Questions? Drop me a line!

Adventures in Computing / tom@mmto.org