Blogging client for Ubuntu

This post is part of my learnings towards movement from Windows to Ubuntu

I have been using Windows Live writer since long , so i was looking for similar kind of software for Ubuntu

After search i found the following alternatives

Blogilo
Drivel
Lekhonee

And one solution for browser based editor can be Scribefire

Similar blog posts

http://www.scaine.net/site/2010/07/blogilo/
http://askubuntu.com/questions/78593/what-blogging-clients-are-available

7 day Ubuntu Challenge for myself

I have been Windows user since pretty long , but not i want to change myself for better things.

So i have challenge for myself to use Ubuntu for one week continuously where ever i am using my own system. I would not be using Windows at all

Just trying to document my learnings as i convert myself from Windowish guy to Nix :P

I would be maintaining my daily learning log on issues which i faced and how i found answers with them.




Exception handling Mindmap

Jasper Reports integration with Liferay

Liferay has one portlet which supports Jasper Reports , but that is not free. It is available only for EE edition people.

Luckily we have one portlet which is free and is based on Jasper reports

http://code.google.com/p/aperte-reports/

I have used it on Tomcat based liferay installation.

Some of the steps and things you need to do

* You need PostgreSQL database , it doenst not work with MySQL. The Postgre SQL based database if used to store internal details which are required for this portlet to work. So dont worry if your liferay install is MySQL or any other it can be used freely.

* Install Postgre and create one database which can be used by aperte-reports portlet

Configure JDBC datasource in tomcat

* In your tomcat context , (generally inside ROOT.xml ) add the following information

<Resource name="jdbc/aperte-reports" auth="Container"

    type="javax.sql.DataSource" driverClassName="org.postgresql.Driver" url="jdbc:postgresql://localhost:5432/aperteDb" username="postgres" password="root" maxActive="20" maxIdle="10" maxWait="-1"/>

aperteDb is database which i created in Postgre for this portlet

* Download the war file of aperte-reports portlet and deploy it

* Download extra jars from

http://jdbc.postgresql.org/download/postgresql-9.1-901.jdbc4.jar

to tomcat lib/ext folder

* Download Vaadin jar from its website

Also download 3 jars of

Vaadin add-ons:

  1. MaskedTextField v0.1.1
  2. ActiveLink v1.0
  3. CKEditor wrapper for Vaadin v1.0

Restart the tomcat and after your portlet deployment is done , you can go to Aperte Reports manager to import jmxml file of ireports into Liferay to create reports and charts

String split and NumberFormatException

Here is one interesting catch

I was trying to convert a string with spaces into various subparts

So i used split method and then tried to convert the individual values into int

While parsing int values i was getting NumberFormatException

That seems very strange at first instance but yes i got it.

After careful notice i found that

19 String[] input = line.split("\\s+");
20 System.out.println(input[0]);
21 int withdrawl = Integer.parseInt("input[0]");

Line 21 already had " " quotes inserted in array generated by the split method

So just


19 String[] input = line.split("\\s+");
20 System.out.println(input[0]);
21 int withdrawl = Integer.parseInt(input[0]);

without quotes was enough to parse the value

The javadoc for split method explains more

The string "boo:and:foo", for example, yields the following results with these expressions:

Regex Result
: { "boo", "and", "foo" }
o { "b", "", ":and:f" }

read the program input from text file

How to set and read the program input from text file instead of keyboard

Other day i was trying to take part in some online programming tests and generally we have to give our program which is compliant to certain guidelines.

One of them is that input has to be given from keyboard.

For testing locally i suggest that you can make one text file to give input all in one go

Some thing like

System.setIn(new FileInputStream(
"D:\\Development\\eclipse_workspace\\RandomInterview\\src\\1.txt"));

This will set the System.in to the text file specified and you can see the output in console.

Happy Programming

Useful link

http://stackoverflow.com/questions/188547/eclipse-reading-stdin-system-in-from-a-file

Use BufferedReader to read line by line

InputStreamReader in = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(in);

String line ;
while ((line = br.readLine()) != null){
System.out.println(line);
}

Earlier i was doing one mistake

invoking readLine() both for checking null and for printing so as a effect the values were skipped and alternate values were being printed. This is due to fact that readLine was called two times and one value was being skipped

Useful resource

http://www.java2s.com/Code/Java/File-Input-Output/UseBufferedReadertoreadlinebyline.htm