Posts Tagged ‘java’

[manjaro] install Oracle Java JDK

December 3, 2014 1 comment

You want to install Oracle Java JDK on Manjaro and you want it to be the default.


$ yaourt jdk

It will produce a list of available Java environments. I chose “aur/jdk 8u25-1 Oracle Java Development Kit”. Type in its number and simply follow the instructions.

At the end you can set this newly installed Java JDK to be the default. In my case it looked like this:

$ archlinux-java status
Available Java environments:
  java-7-openjdk/jre (default)
$ sudo archlinux-java set java-8-jdk
$ archlinux-java status
Available Java environments:
  java-8-jdk (default)

Verify in a new terminal if it’s set correctly: “which java“, “which javac“, “java -version“, “javac -version“.

Categories: manjaro Tags: , , ,

Reindent Java code with Eclipse

April 22, 2012 Leave a comment

I had a Java source that wasn’t correctly indented. How to reindent it painlessly?

In Eclipse:


This tip is from here.

Categories: Uncategorized Tags: , , ,

StringBuilder class in PHP [PHP]

December 3, 2010 1 comment


In PHP you want to construct a long string from pieces.


Instead of string concatenation, it is better to collect the pieces in an array, then at the end put these pieces together in a string. For this we can use the following simple class that works similar to the Java StringBuilder class:

class StringBuilder 
    private $str = array();

    public function __construct() { }

    public function append($str) {
        $this->str[] = $str;
        return $this;
    public function toString() {
        return implode($this->str);


$sb = new StringBuilder();
print $sb->toString();


I found this nice solution in this thread. For append(), I proposed the method chaining possibility.

Categories: php Tags: , , ,

Installing the Java plugin for Firefox

October 28, 2010 Leave a comment


You have a Linux box (e.g. Ubuntu) and you want to run an applet in Firefox. It starts, but then it hangs, and you have no idea what the hack is going on.

My Case

I had Firefox 3.6.3 and I wanted to use OpenCms 7.5.1’s upload feature. The uploading is done via an applet that started but when I chose the file to upload and clicked OK, nothing happened. The CPU was on 100% and using the top command I noticed that a Java process is stuck. A bit later I figured out that it must be the Java plugin…


In Firefox, verify what Java plugin you have. Go to ToolsAdd-onsPlugins. Here I had the icedtea Java plugin. This is a crap, use the official Sun plugin instead.

Open Synaptic and remove this plugin. I also removed all openjdk packages.

Then install these:

sudo apt-get install sun-java6-jdk sun-java6-jre sun-java6-plugin sun-java6-fonts

Now let’s see the list of alternatives:

sudo update-java-alternatives -l

Here I got this output:

java-6-sun 63 /usr/lib/jvm/java-6-sun

Set the official one:

sudo update-java-alternatives -s java-6-sun

Now restart Firefox and check the Java plugin again. You should see Java(TM) Plug-in 1.6.0_22 (or something more up-to-date).


If you cannot install sun-java6-jre because it’s not in the repository, add Canonical Partners to your software sources.


Find more info here.

Categories: firefox Tags: , , , ,

Get every new post delivered to your Inbox.

Join 85 other followers