Friday, August 23, 2013

ECJ Error : Task cannot continue because ECJ is not installed.

Hi all,

Many of java developer use ANT build tool for his project build process. many of us we got this kind of error. so, here i the solution to resolve this.

Please follow below steps...
1) Download ecj.jar file from  this link                                                                                                  "http://mvnrepository.com/artifact/org.eclipse.jdt.core.compiler/ecj/3.5.1"
2)  Goto the   Window -> Preferences 
     (this will display popup windos)

3)  Click On Ant  -> Runtime 

4) Click on Classpath tab 

5) Select Ant Home Entries (Default) option

6) Click on Add External JARs.. button

7) Select Downloaded file from directory -> open

8) Click on Ok


Now, build your project again with ant command. i am sure you will not get this error again.

That's it!!
Enjoy the code!!


Thank you,
Ketan Savaliya

Map Iterator/loop in java

Many time some little things goes our of our mind. Same thing happen in developer life also.So, here i am going to write a small piece of java code which is used daily routine.

Here i am talking about Collection framework Iteration of MAP.

When ever developer need Map almost all time they go to google for how to iterate MAP? so, ans for this question i am going to write small blog about MAP iteration. Bellow is the example for the same.

About Map : Map is part of collection framework. Mainly use to store data in key,value manner. Given a key and a value, you can store the value in a Map object. After the value is stored, you can retrieve it by using its key. now we go through step by step how to use MAP.



1) Declaration of MAP
        Map<String,String> stringMap = new HashMap<String, String>();

2) Store data into MAP

        stringMap.put("1","Apple" );
        stringMap.put("2","Ball");
        stringMap.put("3","Cat");

3) Iteration/Loop/Use of MAP

There are so many ways you can iterate MAP in java. but here i am going to simple way to iterate MAP in java as per my knowledge.
       - by Iterator
       - by EnterySet
       - by keySet

Here we use keySet to iterator MAP. this is very simple way as per my development experiance. like...

         for(String key : stringMap.keySet()){
                 System.out.println("Key : " + key + ", Value : " + stringMap.get(key) );
         }


4) Exmaple

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class test {

    public static void main(String[] s){
       
        Map<String,String> stringMap = new HashMap<String, String>();
        stringMap.put("3","Cat");
        stringMap.put("1","Apple" );
        stringMap.put("2","Ball");
       
        for(String key : stringMap.keySet()){
            System.out.println("Key : " + key + ", Value : " + stringMap.get(key) );
        }
 }

}


5) Output

Key : 3, Value : Cat
Key : 2, Value : Ball
Key : 1, Value : Apple

It's simple right? still we have to go googling for every time to iterate map. i ma sure this blog visit help you remember iteration of map.

That's it!!

Enjoy the code!!


Thank you,
 Ketan Savaliya


Tuesday, August 6, 2013

Web content data display in custom-portlet

Many more time during development we need display liferay web-content in our custom-portlet.
Liferay taglib already give tag to display web-content data.

Here is syntax for "<liferay-ui:journal-article/>"

<<liferay-ui:journal-article showTitle="true/false" articleId="longArticleId" groupId="longGroupId" />


Let take an example...

<<liferay-ui:journal-article showTitle="false" articleId="<%= journalArticleId%>"
groupId="<%= themeDisplay.getScopeGroupId() %>" />

here journalArticleId is long var which is articelId of web-content