Archive for the ‘Java’ Category

The below is a sample implementation of a binary search tree for all beginners out there. The code is pretty self-explanatory.

I shall come out with some interesting operations on the binary (search) tree from time to time basis.

package com.revindran.binarytree.utils;

public class BuildBinaryTree {
       
        static class Treenode{
              Treenode left;
              Treenode right;
              Integer nodeValue;
              
               public Treenode(Integer aValue){
                      this.nodeValue = aValue;
              }
                     
       }
       
        public static void addNode(Treenode rootnode, int value) {
               if (value rootnode.nodeValue) {
                      if (rootnode.right != null) {
                            addNode(rootnode.right, value);
                     } else {
                           rootnode. right = new Treenode(value);
                           System. out.println("Inserted " + value + " to the right of "
                                         + rootnode. nodeValue);
                     }

              }
       }
              
       
        public static void main(String[] args){
              Treenode node1 = new Treenode(5);
               addNode(node1, 6);
               addNode(node1, 1);
               addNode(node1, 7);
               addNode(node1, 4);
               addNode(node1, 3);
               addNode(node1, 0);
       }
       
}

 

I thought I had to post this because of the way people tend to confuse with terminologies used in context with Selenium.

Courtesy to this post: “A Digression about Jargon” section @ http://www.aosabook.org/en/selenium.html

  • Selenium Core is the heart of the original Selenium implementation, and is a set of JavaScript scripts that control the browser. This is sometimes referred to as “Selenium” and sometimes as “Core”.

  • Selenium RC was the name given to the language bindings for Selenium Core, and is commonly, and confusingly, referred to as just “Selenium” or “RC”. It has now been replaced by Selenium WebDriver, where RC’s API is referred to as the “Selenium 1.x API”.

  • Selenium WebDriver fits in the same niche as RC did, and has subsumed the original 1.x bindings. It refers to both the language bindings and the implementations of the individual browser controlling code. This is commonly referred to as just “WebDriver” or sometimes as Selenium 2. Doubtless, this will be contracted to “Selenium” over time.

Back again after a long pause. I was in process of installation of Netbeans 7.1.2 yesterday (about half an hour back before this post :). Its 12:07 in the midnight when I’m keying in this post).

Every time I tried to run the Netbeans installer, I came across the warning message stating that the JDK was not detected. I exit the installation wizard, made a couple of restarts after running the apt-get updates in the terminal. However, the installer fails to detect the JDK installed in the system.

Note: The JDK installed in in Ubuntu 12.04 by default is OpenJDK.

Then finally concluded that will go ahead installing the tried/tested/trusted Oracle-java JDK. There begins the problems. Initially downloaded an rpm package from the Oracle-java site. Extracted the files and copied/pasted them into usr/lib/jvm folder. The NetBeans installer still seemed to be reluctant in detecting the JDK. (Not sure if I was right with this approach).

Then tried converting it to .deb package using alien and still the package failed to dpkg. :(. After being done with all the those manual extractions, I was soon on a look out for an installer package or a method to install it from the terminal with auto-download.

It was then that I came across a couple of sites suggesting to add the repositories and then install the package which too began failing.

Then came this QA site which turned out to be a saver.

It initially asks us to clean up the junk and begin with a fresh installation and this was successful after hours of R&D.

sudo rm /var/lib/dpkg/info/oracle-java7-installer*
sudo apt-get purge oracle-java7-installer*
sudo rm /etc/apt/sources.list.d/*java*
sudo apt-get update
sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

Hope this helps anybody with Ubuntu 12.04 to get over with the issue with installation of Oracle Java 7 and in turn set up IDE's such as NetBeans. I was able to proceed with the installation of NetBeans successfully thereafter.