[ILUG] Java on Linux

Phil Bradley philb at vodafone.ie
Sat Mar 7 12:00:33 GMT 2009


Conor Mac Aoidh wrote:
  > What I wanted to ask is does anyone here know of any books that would
> concentrate on learning Java using Linux? I'm sure once I get to grips with
> the basics that I will be able to show the Windows users how much easier it
> is to program with Java on Linux!

Hi Conor,

The language itself won't be any different, that's part of the design 
goal of Java. If you're programming for the first time, your experience 
will be dominated by the tools chosen by the course designers. What I 
mean by this is that often, when students start, they see the 
development environment as being synonymous with the language. So, if 
they are using JCreator to write Java programs, to them, JCreator "is" 
Java. Of course, this is not true, you can write Java programs in any of 
a number of IDEs (Netbeans, Eclipse, Visual Studio) or just use a 
regular text editor like notepad (or notepad++ which is free and highly 
recommended).

My advice is, don't overly complicate things for the first couple of 
assignments. Do them first on windows using exactly that environment 
recommended by the college. After you get your assignment working, try 
getting it to work on Linux. If you find this works for you, then you 
can just stick with Linux.

Now that I've given you generic advice, here's a quick howto:

1. Java programs are broken into units called classes
2. Each class is defined in a single file (that's only 99% true)
3. Most of your programs in semester 1 will consist of a single class
4. If you create a class called Foo, you must save it in a file called 
Foo.java, you have no choice about this.
5. To compile Foo.java, just use the following command line:

javac Foo.java

This produces a file called Foo.class. To run it, use the following command:

java Foo


In reality, real programs written in Java consist of many classes (and 
hence many files). A single developer might easily have a few hundred 
classes making up their project. This is why complicated IDEs like 
Netbeans and Eclipse are used, they keep track of all of your classes 
and look after the compilation automatically along with many other 
helpful but initially distracting features.

In the long run, developing Java on Linux should present no problems, 
it's well supported and lots of people do it but it's important when 
you're learning the fundamentals, to try separate your concerns as much 
as possible.

Cheers,
  -phil








More information about the ILUG mailing list