How to change JDK in Linux

Linux Mint or Ubuntu may come with the OpenJDK Java compiler and runtime. If you need to work the Sun version of the Java development kit, you will need to download it. You can do this using the Synaptic app or just open a Terminal window, press ALT-F2, then type gnome-terminal sudo apt-get install sun-java6-jdk [...]

How to accept input from keyboard

If you need to write interactive text-based application in Java, you will need a way to accept input from the keyboard; sure you can get it from the command line, but at some point, you will need to prompt the user for an input and store that input somewhere in your code for later processing. [...]

Multiplication table using 2 for loops in Java

I saw this search term coming up over and over again in my wp-stats, I would guess that this is a school assignment–for those beginning to get into grips with Java language, this is how to generate the Multiplication table using 2 for loops; you could use another kind of loop, but using ‘for’ is [...]

Starting database programming in Java

Database programming is probably one of the most common tasks that you will encounter in your programming career–in fact, during job interviews, it is an expectation that you know how to deal with the most common databases in use–like for example, MySQL, Oracle, MS SQL Server and many others. Java database programming can get hairy [...]

How to peek quickly inside the .class files using javap

If you need just need to quickly see the name of the methods of a specific Java class or you want to take a look at a disassembled code, you can use javap. If your JDK is properly installed and you have setup your PATH and CLASSPATH properly, then you can already use javap–it’s executable [...]

Installing Tomcat 6 on Snow Leopard

Snow Leopard comes with Java 6, so Tomcat installation wasn’t much of a problem. The procedure involved just downloading the Tomcat 6 binaries from the Tomcat download site, I downloaded the tar.gz portion of the Core packages. The next step steps were to copy the Tomcat package to the home folder (you can put it [...]

Declaring an array filled with Objects

class ArrayEx tries to create an array of java.lang.Object(s), but it won’t. All it will do is to create an array of 4 elements, but each of the element will contain null. Unlike declaring and initializing Java primitives where the array elements will be populated automatically with the default primitive values (int, short, boolean, float [...]

Abstract classes

A class with at least one abstract method, is an abstract class (should be defined as an abstract class) – by this definition, a Java class becomes concrete when the following 2 conditions are met. There are no abstract methods defined inside the class The abstract modifier is not preceding the class keyword on the [...]