Java on Linux with multiple JDKs (Old, 2010)

Recently one of our linux servers at work crashed and died. I decided this time to skip the packages that come with the system and just come up with a more flexible way of compiling and running Java code.

May as well have multiple versions of Java. At the time I was coding in 1.5 so I needed a jdk5. But as I moved into the later testing phases of an application, I wanted to try some of the applications monitoring features in Java 6. So, to cover multiple bases, multiple JDKs.

First you want to download, I assume for all of us here, Java 5 and Java 6, jdk, sdk, the whole kit and caboodle!

Since the is all about options I like to:
1. Install the different versions of Java in /opt at the root level. You should be able to do this by typing ./java-file-you-downloaded.bin

2. Write a shell script that will set the Java version and location at run time. Just add, if using bash shell, export JAVA_HOME=/opt/jdkversion, and other path and classpath exports you need.

Using bash shell:

#! /bin/bash

export JAVA_HOME=/opt/jdk1.5.0_18
export PATH=$JAVA_HOME/bin:$PATH

3. Add to the shell script a call to your Java class.
java -classpath .:./moreDir:./anotherDir package.javaclass.class or no .class depending on your jdk

Now you can write shell scripts to compile, and run your code with different versions of Java just by creating a shell script!

The Beauty of Java Hashtable (Old, 2010)

Sometimes newbies can’t quite grasp how to use Java to get data from a database in an easy way.
A simple hashtable goes a long way in web development. for instance:

String sql = “select name,age,dob from employee”;

//notice the use of String key and Object value, since data from the database comes in many forms:Decimal,varchar,boolean
Hashtable<String,Object><string,object><string,object><string,object> employees = new Hashtable<string,object><string,object><string,object><String,Object><string,object>();

int count 0;

ResultSet rs = statement.executeQuery();
while(rs.next()){

employees.put(“name”+count,rs.getString(“name”));
employees.put(“age”+count,rs.getString(“age”));
employees.put(“dob”+count,rs.getString(“dob”));
count++;
}
This simple routine will give the novice developer a new weapon to his her arsenal.
Here we have a generic way store database data in an array.
If the data was all varchar, which is Java String, we could have created a hashtable with a signature of <String,String><string,string>. However, <String,Object>String,Object> gives the flexibility we need.

Don’t forget to increment that counter!

Catch The Cloud (Old, 2010)

Cloud Computing is slowly establishing itself as the backbone of large corporations, startup companies and independents all alike. The timeline of online technology as it descended into the dotcom bomb and arose from the ashes like a phoenix is a classic store of nothing to something.

In the beginning there was the Internet with new websites popping up daily. Can you recall all the early ‘Social Media’ sites, like ubo.net? It had everything I wanted but at the same time nothing. There were links to things I knew people like me were interested; the local event, restaurants, music, etc… The problem with these companies is that there was no true value in their web presence. Think about having a staff of information technology specialists, marketing department and the whole nine yards, but you have no true stream of revenue. That is what many companies faced in the mid to late 90s. No bottom line, hence, the dotcom bomb destroyed companies these companies.

Fast-forward to 2010 and businesses have a better understanding of technology and how it does more than act as a showpiece. In the financial services industry we have Cloud Computing serving as virtual work staff. Salesforce.com, one of, if not the largest, Customer Relationship Management (CRM) platform and has grown to over a billion dollars in assets in less than 10 years reaching into all facets of business like Lead Management for E-Trade Financial and global collaboration with business partners for Dell Computers. Cloud Computing allows smaller entities to live a better existence in their industry with Cloud based services. The cost of Cloud based services is dwarfed when compared to keeping an in house staff of information technology professionals. This is news golden for startups and independents.

ElasticSearch – Taking The NoSQL Plunge

I cannot tell a lie!

I have fallen in love with ElasticSearch. The ELK (ElasticSearch, Logstash & Kibana) Stack to be exact. Why?

UI: As I developer spending a lot of time on the back end and the middle end, we don’t think about how were going to get that sexy user interface up and running. In my case, the team is small, we have one UI developer, so time is of the essence. Out the box, Kibana provides a fantastic user interface. The UI is mostly mostly point and click. Think Google Analytics with statistical functions built into the UI for you to manipulate.

NoSQL: Never been interested in a game of darts, but ElasticSearch is the ultimate “dart board”. I can throw any record, with any fields without having to worry about matching table structure. Sure, we could right apps that database alter tables, but this is A.D. not B.C!

Data Injection: I’m a sucker for CSV files. Simple and convenient. But an SQL statement to get the same data is even better. Logstash allows you inject your data into ElasticSearch with ease, via different methods, like the two aforementioned.