Tag Archives: Java

Install Sun Java under Debian Squeeze

Debian Squeeze for AMD64 comes with OpenJDK Java preinstalled and ready to run. If you, for whatever reason, need to install Sun Java, the Sources list has to be modified:

Edit /etc/apt/sources.list, add “non-free”:

deb http://ftp2.de.debian.org/debian squeeze main non-free


ron@ron:~$ apt-get update

Check for available Sun Java Packages:

ron@ron:~$ apt-cache search sun-java6

The result may look something like this:

sun-java6-bin - Sun Java(TM) Runtime Environment (JRE) 6 (architecture dependent files)
sun-java6-demo - Sun Java(TM) Development Kit (JDK) 6 demos and examples
sun-java6-doc - Sun JDK(TM) Documention -- integration installer
sun-java6-fonts - Lucida TrueType fonts (from the Sun JRE)
sun-java6-javadb - Java(TM) DB, Sun Microsystems' distribution of Apache Derby
sun-java6-jdk - Sun Java(TM) Development Kit (JDK) 6
sun-java6-jre - Sun Java(TM) Runtime Environment (JRE) 6 (architecture independent files)
sun-java6-plugin - The Java(TM) Plug-in, Java SE 6
sun-java6-source - Sun Java(TM) Development Kit (JDK) 6 source files

Now install what you need, minimum is sun-java6-bin:

ron@ron:~$ apt-get install sun-java6-bin sun-java6-javadb sun-java6-jdk sun-java6-plugin

In order to accept the License Agreement, navigate to the Accept field with TAB.

Make Sun Java the Java runtime of your choice:

ron@ron:~$ update-java-alternatives -s java-6-sun

Check, if Java could be properly installed:

ron@ron:~$ java -version

java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03, mixed mode)

Set Environment Variable $JAVA_HOME

Edit file /etc/profile, add:

export JAVA_HOME


Switch hates me…

After all, my ignorance caused a complicated troubleshooting on an control structure of a Java method: a ‘break’ was missing. But what happened? Reason enough for some thoughts about the Switch Case syntax, something, we all, of course, know very well.

The following code

int x = 1;
switch (x) {
 case 1:
	System.out.println( "1" );
 case 2:
	System.out.println( "2" );
 case 3:
	System.out.println( "3" );
	System.out.println( "default" );
} // switched

prints on the command line:


Changing the value of the variable x to 3, prints:


Nothing changes, if you move the default block before the first case block, as long as the value of the switch variable is found in any case expression.

Only if the default block is before the first case block and the value of the switch variable is not found in any case expression, the default block and all case blocks will be executed, until a ‘break’ is found or the end of the switch structure is reached.

In short: If a ‘break’ statement is missing after a case block, all following case blocks will be executed, whether the case expression is true, or not. This continues until a ‘break’ or the end of the switch structure is reached and is called fall-through.

This behaviour is identical in PHP.