My fears to Experiment (Learning challenges)

Living in peace as some people believe, is a factor of how much trouble you cause for yourself. ‘I would rather not try it than trying it and getting myself into trouble’.

This made me remember my university days at the time when I just got my 512 megabyte RAM Acer laptop. I had worked on desktop windows computers for a while before that time and so I could boast of being able to try my hands on some default applications, Microsoft word being the most popular. With that seemingly great knowledge, I could say the laptop was not extremely useless in my hand on the one hand. On the other hand, I often tried to go beyond my knowledge limit and experiment with the system, maybe trying to press the F8 key while I had just switched on my computer, looking forward to knowing what is really working in the whole system and why and how is a computer system formatted. Sometimes I would think of my 3 gigabytes saved videos and documents; what happens to all that if I go ahead is the question that comes to my mind and then I would rather not try to proceed in my experiments and even sometimes when I try, I find myself in a mess of the system, running to a friend who luckily would not ask me to pay.

Life is full of risks and challenges; therefore, trying to stay safe by avoiding all challenges also has its disadvantages. Ben Carson, the great neurosurgeon in one of his books, ‘Take the risk’ explained a way by which he takes decisions using the best and worst case analysis. There are some risks one would have to take to achieve some goals in life; these may be different as regards specific types of career paths or even one’s determination.

There is a popular saying that ‘experience is the best teacher’ and in the context of this note I would like to define experience as an act that is acquired through practice. In a piece, titled CodeKata (how to become a better developer) , on codkata.pragprog.com The writer emphasized the need for programmers and developers to create time for practice instead of always trying to learn on the job through live applications, problems or errors. This implies that one can actually learn a lot of things in the corner of one’s room by creating experiences which are in most cases only known to you. Sometimes some of your experiments may be costly but as rightly said, ‘failure does not come when you try something and it did not work as expected, it comes when you refuse to try again’.

Back to the story of my university days, I discovered the need to really give a trial to some of my wishes and closed my eyes to every bit of fear that had discouraged me from experimenting. I got some additional tools and software even though I did not know the correct configuration or specifications needed, I just wanted to try. After all, it was my laptop. To cut the story short, after days of continual practice, I discovered I started understanding some terms that emanates when my so called techie-friends were discussing, I was able to pick one or two corrections for my mistakes and I very much appreciated watching people work on faulty or dead systems.

Items and materials around you especially the ones you own are subjected to you and in no way is it sensible for you to make them control you. Decide what you want and try it out, it could be a great resource to your long awaited breakthrough. Even if your environment says no, you have got to be determined to say yes.

Advertisements

In mind but not in sight

Picking a career is in parts: an individual will always have in mind the nature of what (s)he would like to be or do in life and at the same time, the situation or circumstances in which you find yourself suggests what you should be.

Today, we see Microsoft and we think of Bill gates, the founder, a question that should actually come to one’s mind is if he (Bill Gates ) actually attended any institution where he was taught ‘Microsoft’ or did he graduate from an institution with a discipline that is related to computing or the Information communication Technology industry? In Bill gate’s biography here, he was known to have dropped out of Harvard University because of his interest in ICT so to say and here comes readily an answer to the question, which is that an individual has the ability to become ‘what he is’ in his mind as well as what the environment presents. The ICT career is such a career that a lot of people, even without a high school grade not to talk of a university degree, have been successful with.

In some parts of the world, especially the developing nations, the environment instills a particular kind and type of profession and steps to career achievement, take for example, a child who is constrained to attend a primary school, Junior and high school in which he/she chooses to be in the science class to be taught some specific types of courses like Biology and chemistry and then get admitted into the university along the same line of courses. In some cases, this is done as a ‘do or die’ affair especially when the child does not really have interest in the choice.

Sometimes ago I had a thought on how the exploration rate of human beings decrease with age. A three to four year old child would like to experiment anything (everything) to the extent of even wanting to check what is burning inside a flame. This spirit diminishes as we grow and all tends to be naturally streamlined.

With the great potential that you have been endowed with, considering what your mind says you should be, should not be a taboo. There are people who look up to some specific people in the ICT world (a situation in which I was) and say in their heart “I wish I could be like him or her”, yes you can, all you need is a bold and focused step towards achieving your goal. At the initial stage, you might not have an hundred percent clue about where you are going but just keep moving.

Having a career in the ICT industry is a very interesting opportunity as a great percentage of members enjoy what they do. Things are made to work especially in the modern world and virtually one is able to achieve to a great extent at maximum. Interesting news and events come up daily with creative ideas and structural constructions you can use your time for. I would not want to talk about the big world of financial reward that follows a successfully designed and completed project.

All I have written about starts with a little step.  Make a use of the tools around you; learn how some simple applications that you will necessarily have on your computer system work and just continue to learn until there is nothing you have to learn.

Some Spring mvc errors and solutions

Below are some of the errors you are likely to encounter in eclipse when developing a spring mvc applications. The solution to the errors have been made in bold letters below each.

INFO: Loading XML bean definitions from file [C:\Utilities\Eklipse\SpringDemo\spring.xml]
Exception in thread “main” org.springframework.beans.factory.xml.XmlBeanDefinitionStoreException: Line 2 in XML document from file [C:\Utilities\Eklipse\SpringDemo\spring.xml] is invalid; nested exception is org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’.
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:396)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:334)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:73)
at org.springframework.beans.factory.xml.XmlBeanFactory.<init>(XmlBeanFactory.java:61)
at com.tunji.dkreators.DemoMain.main(DemoMain.java:14)
Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’.
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
at com.sun.org.apache.xerces.internal.util.ErrorHandlerWrapper.error(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLErrorReporter.reportError(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.handleStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl$NSContentDriver.scanRootElementHook(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl$PrologDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at org.springframework.beans.factory.xml.DefaultDocumentLoader.loadDocument(DefaultDocumentLoader.java:75)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.doLoadBeanDefinitions(XmlBeanDefinitionReader.java:388)
… 5 more
What does it mean when you get an error like this in spring framework development

Ans: If you look critically at the ‘Caused by’ section, it simply means either you did not create an xml file you have decleared in your main file
and so it could not be found during the running process.

“Caused by: org.xml.sax.SAXParseException: cvc-elt.1: Cannot find the declaration of element ‘beans’.”

Kindly create the xml file.
===============================================================================================================================
2. INFO: Refreshing org.springframework.context.support.ClassPathXmlApplicationContext@c1b531: startup date [Tue May 29 06:42:18 PDT 2012]; root of context hierarchy
May 29, 2012 6:42:19 AM org.springframework.beans.factory.xml.XmlBeanDefinitionReader loadBeanDefinitions
INFO: Loading XML bean definitions from class path resource [spring.xml]
Exception in thread “main” org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [spring.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:341)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:302)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:143)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:178)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:149)
at org.springframework.beans.factory.support.AbstractBeanDefinitionReader.loadBeanDefinitions(AbstractBeanDefinitionReader.java:212)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:126)
at org.springframework.context.support.AbstractXmlApplicationContext.loadBeanDefinitions(AbstractXmlApplicationContext.java:92)
at org.springframework.context.support.AbstractRefreshableApplicationContext.refreshBeanFactory(AbstractRefreshableApplicationContext.java:130)
at org.springframework.context.support.AbstractApplicationContext.obtainFreshBeanFactory(AbstractApplicationContext.java:465)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:395)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:139)
at org.springframework.context.support.ClassPathXmlApplicationContext.<init>(ClassPathXmlApplicationContext.java:83)
at com.tunji.dkreators.DemoMain.main(DemoMain.java:14)
Caused by: java.io.FileNotFoundException: class path resource [spring.xml] cannot be opened because it does not exist
at org.springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:141)
at org.springframework.beans.factory.xml.XmlBeanDefinitionReader.loadBeanDefinitions(XmlBeanDefinitionReader.java:328)
… 13 more

Ans: This simply means you have to create or move your xml file into the classpath which is usually the src folder.

 

Hope you found this useful.

A Comment on Chad Fowler’s Book

After reading Chad Fowler’s book, titled ‘My job went to India…’, I decided to put up this piece about the author. Simply put, Chad is someone that has a good understanding of the Information Communication Technology world; his book answered a lot of questions that most newbies and even experienced programmers or developers of today would often ask.

Apart from this book which is enriched with the analysis of the author’s practical experience in India, he also has a publication titled ‘The passionate programmer’ and some others on the Ruby programming language.

This book is a must read for all, especially in the ICT industry, and in essence, not all about reading but putting to use the practical ideas that were given.

Android Currency USD to NGN naira converter

Getting ones and on an android application development feels good sometimes, especially when you have been able to scale through the hurdles of the initial setup of eclipse.

Here we have a simple android application that converts the US dollars to the Nigerian naira. Although the rates are currently being hard-coded, an upgrade is going on to fetch them online and that would be released soon. And this application could also be enhanced to convert in more than one currency.

Going through the process of the development of this application, although so much dependent on an existing example, in a way I thought there was no need putting it on my blog but on another note I felt it would be a good platform for  android newbies to move a step further.

Now go on with me to the next step as I explain an easy way of achieving this or even something greater.

Steps

1.       Get eclipse IDE(Integrated Development Environment) installed on your system

I have had ,Eclipse Java EE IDE for Web Developers. Version: Helios Service Release 2 Build id: 20110218-0911’ on my system for some time now and believe me, it has really being a great tool to work with having used it for a lot of developments out of android. In building this application all I needed to do was to complete the needed setup for the android part of eclipse and then was I able to fire on with my development. You might decide not to use eclipse for your own development, but giving it a trial is not in any way bad as well. To download and install eclipse, this is the link. http://www.eclipse.org/downloads/

2.       Get Android installed and configured.

After you have downloaded the needed version of eclipse( usually Eclipse Classic 3.5 (Galileo)) the next step is to go ahead and make the necessary android installation and configuration. The link below should help you in doing that. http://www.londatiga.net/it/how-to-setup-android-application-development-on-eclipse/   Please note that for people in countries like Nigeria in which people do not really have extremely fast bandwith, there might be some challenges in achieving the first two steps above and I bet you, one might not be able to move a step further without getting them set.  

3.       Set up an emulator

The purpose of this is to be able to test you application during and after development and see it the way it would work on an android appliance. http://grail.cba.csuohio.edu/~matos/notes/cis-493/lecture-notes/Android-Chapter02-Setup2-Emulator.pdf

4.       Make your application

Depending on the complexity of the app you want to develop, which I believe should not be complicated at this time, eclipse  avails you the opportunity to easily get an application built in no time.   In eclipse, create a new android project and paste the code below into the script below into the res/layout/main.xml file .  

<?xml version=“1.0” encoding=“utf-8”?>

<RelativeLayout

android:id=“@+id/widget32”

android:layout_width=“fill_parent”

android:layout_height=“fill_parent”

xmlns:android=http://schemas.android.com/apk/res/android&#8221;>

<LinearLayout

android:id=“@+id/widget34”

android:layout_width=“250dp”

android:layout_height=“350dp”

android:layout_alignParentLeft=“true”

android:layout_alignParentTop=“true”

android:orientation=“vertical” >

<TextView

android:id=“@+id/dollar”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“”

android:hint=“USD” />

<EditText

android:id=“@+id/dollars”

android:layout_width=“100dp”

android:layout_height=“40dp”

android:text=“100”

android:textSize=“18sp” />

<TextView

android:id=“@+id/nair”

android:layout_width=“100dp”

android:layout_height=“30dp”

android:text=“NGN”

android:textSize=“18sp” />

<EditText

android:id=“@+id/naira”

android:layout_width=“100dp”

android:layout_height=“40dp”

android:text=“160”

android:textSize=“18sp” />

<RadioGroup

android:id=“@+id/widget48”

android:layout_width=“210dp”

android:layout_height=“80dp” >

<RadioButton

android:id=“@+id/dton”

android:layout_width=“200dp”

android:layout_height=“30dp”

android:text=“USD to NGN” />

<RadioButton

android:id=“@+id/ntod”

android:layout_width=“200dp”

android:layout_height=“30dp”

android:text=“NGN to USD” />

</RadioGroup>

<Button

android:id=“@+id/convert”

android:layout_width=“100dp”

android:layout_height=“40dp”

android:layout_marginRight=“26dp”

android:layout_marginTop=“16dp”

android:text=“Convert” />

</LinearLayout>

</RelativeLayout>

After that, copy the following code and paste it in a default java file that eclipse created.  

package com.tunji.android;

import android.*;

import android.app.Activity;

import android.view.View;

import android.view.View.OnClickListener;

import android.widget.Button;

import android.widget.RadioButton;

import android.widget.TextView;

import android.os.Bundle;

public class CurrencyActivity extends Activity implements OnClickListener {

TextView dollars;

TextView naira;

RadioButton dton;

RadioButton ntod;

Button convert;

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(R.layout.main);

dollars = (TextView)this.findViewById(R.id.dollars);

naira = (TextView)this.findViewById(R.id.naira);

dton = (RadioButton)this.findViewById(R.id.dton);

dton.setChecked(true);

ntod = (RadioButton)this.findViewById(R.id.ntod);

convert = (Button)this.findViewById(R.id.convert);

convert.setOnClickListener(this);

}

public void onClick(View v) {

if (dton.isChecked()) {

convertDollarsToNaira();

}

if (ntod.isChecked()) {

convertNairaToDollars();

}

}

protected void convertDollarsToNaira() {

double val = Double.parseDouble(dollars.getText().toString());

// in a real app, we’d get this off the ‘net

naira.setText(Double.toString(val*157.00));

}

protected void convertNairaToDollars() {

double val = Double.parseDouble(naira.getText().toString());

// in a real app, we’d get this off the ‘net

dollars.setText(Double.toString(val/157.67));

}

}

5.       Run your application and view your application if there are no hitches.

Although there is a slim chance of everything working smoothly at the very first attempt, here are some links below that could assist in some of the challenges you face. It is however important that you find out what a problem is by searching and reading about the error messages or logs before you start troubleshooting. Else, you might end up muddling up all the application and not knowing where to go from there.   http://www.coderanch.com/t/510807/Android/Mobile/Could-not-find-HelloAndroid-apk http://stackoverflow.com/questions/2793956/android-emulator-wont-run-application-started-from-eclipse I hope this helps, please post your comments and observations and let me know if this helps you. I am also available to assist further if you are experiencing some other forms of challenges as regards this.  

Regards                                                                                   

Dogs barking simple java simulation

Just thought of what to do today and i came up with this simple java code that barks at me when i run it.

Mind you, considering the need for simplicity, the barking has being made in terms of words and not a sound format which is also achievable as might be posted in the future. Below is my code and feel free to make comments, add or subtract from it as you wish.

package com.tunji.dog;

class Dog{

int size;
String breed;
String name;
boolean healthy;

void bark(){
System.out.println(“ruff! ruff!!”);
}

class DogTest{  //this could be saved as another class.

public static void main(String[]args){
Dog c = new Dog();
c.size = 40;
c.breed = “bull”;
c.name = “coaster”;
c.healthy = true;
c.bark();

}
}

 

Regards.

Installation of the JDK on a RedHat Linux System

Installing the JDK on a RedHat Linux System

Today, i feel i should share a solution to another very important process that causes some hitches especially for coders and developers that are to a certain extent upcoming.

It is about the simple java installation on linux redhat.

Ordinarily on a newly installed Redhat Linux server, you might not get a java installation that you desire or even none at all. If you are in such a position then i am happy you got to this blog.

In this post I will describe how to install a JDK on your RedHat Linux server. It should also work on Fedora, however I have not tried it personally.

1. First we need to download a JDK. I am downloading JDK 6u1 from http://java.sun.com/javase/downloads/index.jsp.
Go to that page and click the Download button. On the new page that loads, we will download the Linux RPM in self-extracting file. You can contact me if you are having a challenge doing that.
2. Once you have downloaded your file, and have it placed somewhere on your Linux box (I put mine in /root/jdk), we will extract and install it. The name of the file I downloaded was jdk-6u1-linux-i586-rpm.bin.
3. Login to your Linux box as the root user, and change directory to where you placed the jdk file that you downloaded.
4. Make sure the file you downloaded is executable.

chmod 755 jdk-6u1-linux-i586-rpm.bin

5. Now run the file.

./jdk-6u1-linux-i586-rpm.bin

6. A license agreement will appear on your screen displayed through the more command.
Simply press the enter key until you get to the end, or just press the q key to skip right to the end.
7. At the end of the agreement, type yes to agree to it and continue with the install.
8. The JDK will now unpack and install itself. Your screen output should look similar to the following:

Unpacking…
Checksumming…
Extracting…
UnZipSFX 5.50 of 17 February 2002, by Info-ZIP (Zip-Bugs@lists.wku.edu).
inflating: jdk-6u1-linux-i586.rpm
Preparing… ########################################### [100%]
1:jdk ########################################### [100%]
Unpacking JAR files…
rt.jar…
jsse.jar…
charsets.jar…
tools.jar…
localedata.jar…
plugin.jar…
javaws.jar…
deploy.jar…

Done.

9. The install routine installs the files into the directory /usr/java/jdk1.6.0_01. It also creates two links in that directory named default and latest.
It’s about time Sun has done this. I have been manually doing something like this since the JDK 1.2 days.
These links make it easy to migrate to a new JVM, as you would reference the link in your shell scripts and not the actual JVM directory itself.
10. Now we want our system to automatically put the JDK binary files into our PATH when we login for all users.
To do this, edit the /etc/profile file and place the following two lines at the bottom of your file:

JAVA_HOME=/usr/java/default; export JAVA_HOME
PATH=$JAVA_HOME/bin:$PATH; export PATH

11. Now if you logout of your system and then log back in, you should be able to run the java command to print its version. Run the following command:

java -version

And your output should look like:

java version “1.6.0_01”
Java(TM) SE Runtime Environment (build 1.6.0_01-b06)
Java HotSpot(TM) Client VM (build 1.6.0_01-b06, mixed mode, sharing)

12. Congratulations, your JDK is installed!

 

Regards.

How do you send heavy files?

This post i believe might not be read by all but believe me would most likely be useful to all, take a look at the points below:

Do you spend a quality time with you computer and crave acquire more knowledge daily.?

Do you have contacts that you do some form of work or another together, thereby involving you sending some files or even documents?

If the two questions above applies to you then i think you should consider this post.

Many people have mastered the means of sending documents and files through the electronic mails especially when they are not heavy as i know gmail allows files (not executable) of sizes not more than 25 mb. However, what happens when you are to send a 2 gigabyte document to a colleague in another location. Do you sometimes take physical transfer as an option?

http://www.4shared.com is a site i discovered some years back; although being a very popular site, many people still seem not to know about it or what it does.

The function is very simple and it is that you can have up to 15 gigabyte memory free to yourself to store files or send files, just like you manage your email addresses.

To a very good extent, this i think has eliminated the nightmare of not knowing how to send heavy files to any part of the world, especially for those who deal with executable files and other forms of files of folder which can not be sent by ordinary mails.

Follow the steps below to get started using 4shared for free. You can decide to upgrade your account at anytime paying a token if you feel 15 gigabyte will be too small for you to use.

1. visit http://www.4shared.com and sign up

2. You can login with your username and password and then upload whichever files you want to.

3. Copy the url link of your uploaded file and you can send just that to whoever is going to download.

NB: The ‘downloader’ will also have to be a registered member of 4shared but only those who have the link will be able to download the file as long as it still exist in your box. This means that you can decide to delete your upload as soon as the other party has finished the download.

Hope this post was helpful?  please let me have your comments or contact me for further clarification.

Regards.

Starting afresh with Java Programming.

From my little years of experience with java, i have decided to start a blog post here which will take you through some aspects i believe you need to become a good java programmer. While i am preparing to start the classes, i feel you can just place your comments and suggestions here to fire me on.

Stay tuned.

Java program to read and sort figures from a text file

package com.tunji.coursera;

/*This program collects integers and sorts them in either ascending or
descending order as picked in the options given.
There is a need for an enhancement for the program to pick the arrays from
a text file. */

import java.io.*;
import java.util.*;

public class PickSortMerge {

public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new FileReader(“C:\\Utilities\\Textpad programs\\com\\tunji\\coursera\\numbers.txt”));
Map<String, String> map=new TreeMap<String, String>();
String line=””;
while((line=reader.readLine())!=null){
map.put(getField(line),line);
}
reader.close();
FileWriter writer = new FileWriter(“C:\\Utilities\\Textpad programs\\com\\tunji\\coursera\\pro.txt”);
for(String val : map.values()){
writer.write(val);
writer.write(‘\n’);
}
writer.close();
}

private static String getField(String line) {
return line.split(” “)[0];//extract value you want to sort on
}
}