mardi 6 décembre 2016

Top 10 Tricky Java interview questions and Answers

10 Tricky Java interview question - Answered

Here is my list of 10 tricky Java interview questions, Though I have prepared and shared lot of difficult core Java interview question and answers, But I have chosen them as Top 10 tricky questions because you can not guess answers of this tricky Java questions easily, you need some subtle details of Java programming language to answer these questions.
Question: What does the following Java program print?
public class Test {
    public static void main(String[] args) {
        System.out.println(Math.min(Double.MIN_VALUE, 0.0d));
    }
}
Answer: This question is tricky because unlike the Integer, where MIN_VALUE is negative, both the MAX_VALUE and MIN_VALUE of the Double class are positive numbers. The Double.MIN_VALUE is 2^(-1074), a double constant whose magnitude is the least among all double values. So unlike the obvious answer, this program will print 0.0 because Double.MIN_VALUE is greater than 0. I have asked this question to Java developer having experience up to 3 to 5 years and surprisingly almost 70% candidate got it wrong.

What will happen if you put return statement or System.exit () on try or catch block? Will finally block execute?
This is a very popular tricky Java question and it's tricky because many programmers think that no matter what, but the finally block will always execute. This question challenge that concept by putting a return statement in the try or catch block or calling System.exit() from try or catch block. Answer of this tricky question in Java is that finally block will execute even if you put a return statement in the try block or catch block but finally block won't run if you call System.exit() from try or catch block.


Question: Can you override a private or static method in Java?
Another popular Java tricky question, As I said method overriding is a good topic to ask trick questions in Java. Anyway, you can not override a private or static method in Java, if you create a similar method with same return type and same method arguments in child class then it will hide the superclass method, this is known as method hiding.
Similarly, you cannot override a private method in sub class because it's not accessible there, what you do is create another private method with the same name in the child class.



Question: What do the expression 1.0 / 0.0 will return? will it throw Exception? any compile time error?
Answer: This is another tricky question from Double class. Though Java developer knows about the double primitive type and Double class, while doing floating point arithmetic they don't pay enough attention to Double.INFINITY, NaN, and -0.0 and other rules that govern the arithmetic calculations involving them. The simple answer to this question is that it will not throw ArithmeticExcpetion and return Double.INFINITY.

Also, note that the comparison x == Double.NaN always evaluates to false, even if x itself is a NaN. To test if x is a NaN, one should use the method call Double.isNaN(x) to check if given number is NaN or not. If you know SQL, this is very close to NULL there. 
Does Java support multiple inheritances?
This is the trickiest question in Java if C++ can support direct multiple inheritances than why not Java is the argument Interviewer often give. Answer of this question is much more subtle then it looks like, because Java does support multiple inheritances of Type by allowing an interface to extend other interfaces, what Java doesn't support is multiple inheritances of implementation. This distinction also gets blur because of default method of Java 8, which now provides Java, multiple inheritances of behavior as well.


What will happen if we put a key object in a HashMap which is already there?
This tricky Java question is part of another frequently asked question, How HashMap works in Java. HashMap is also a popular topic to create confusing and tricky question in Java. Answer of this question is if you put the same key again then it will replace the old mapping because HashMap doesn't allow duplicate keys. The Same key will result in the same hashcode and will end up at the same position in the bucket.
 Each bucket contains a linked list of Map.Entry object, which contains both Key and Value. Now Java will take the Key object from each entry and compare with this new key using equals() method, if that return true then value object in that entry will be replaced by new value.



Question: What does the following Java program print?
public class Test {
    public static void main(String[] args) throws Exception {
        char[] chars = new char[] {'\u0097'};
        String str = new String(chars);
        byte[] bytes = str.getBytes();
        System.out.println(Arrays.toString(bytes));
    }
}

Answer: The trickiness of this question lies on character encoding and how String to byte array conversion works. In this program, we are first creating a String from a character array, which just has one character '\u0097', after that we are getting the byte array from that String and printing that byte. Since \u0097 is within the 8-bit range of byte primitive type, it is reasonable to guess that the str.getBytes() call will return a byte array that contains one element with a value of -105 ((byte) 0x97).

However, that's not what the program prints and that's why this question is tricky. As a matter of fact, the output of the program is operating system and locale dependent. On a Windows XP with the US locale, the above program prints [63], if you run this program on Linux or Solaris, you will get different values.

To answer this question correctly, you need to know about how Unicode characters are represented in Java char values and in Java strings, and what role character encoding plays in String.getBytes().

In simple word, to convert a string to a byte array, Java iterate through all the characters that the string represents and turn each one into a number of bytes and finally put the bytes together. The rule that maps each Unicode character into a byte array is called a character encoding. So It's possible that if same character encoding is not used during both encoding and decoding then retrieved value may not be correct. When we call str.getBytes() without specifying a character encoding scheme, the JVM uses the default character encoding of the platform to do the job.

The default encoding scheme is operating system and locale dependent. On Linux, it is UTF-8 and on Windows with a US locale, the default encoding is Cp1252. This explains the output we get from running this program on Windows machines with a US locale. No matter which character encoding scheme is used, Java will always translate Unicode characters not recognized by the encoding to 63, which represents the character U+003F (the question mark, ?) in all encodings.


If a method throws NullPointerException in the superclass, can we override it with a method which throws RuntimeException?
One more tricky Java questions from the overloading and overriding concept. The answer is you can very well throw superclass of RuntimeException in overridden method, but you can not do same if its checked Exception.


What is the issue with following implementation of compareTo() method in Java
public int compareTo(Object o){
   Employee emp = (Employee) o;
   return this.id - e.id;
}
where an id is an integer number.
Well, three is nothing wrong in this Java question until you guarantee that id is always positive. This Java question becomes tricky when you can't guarantee that id is positive or negative. the tricky part is, If id becomes negative than subtraction may overflow and produce an incorrect result.



How do you ensure that N thread can access N resources without deadlock?
If you are not well versed in writing multi-threading code then this is a real tricky question for you. This Java question can be tricky even for the experienced and senior programmer, who are not really exposed to deadlock and race conditions. The key point here is ordering, if you acquire resources in a particular order and release resources in the reverse order you can prevent deadlock.


Question: Consider the following Java code snippet, which is initializing two variables and both are not volatile, and two threads T1 and T2 are modifying these values as following, both are not synchronized
int x = 0;
boolean bExit = false;

Thread 1 (not synchronized)
x = 1; 
bExit = true;

Thread 2 (not synchronized)
if (bExit == true) 
System.out.println("x=" + x);
Now tell us, is it possible for Thread 2 to print “x=0”?

Answer: It's impossible for a list of tricky Java questions to not contain anything from multi-threading. This is the simplest one I can get. Answer of this question is Yes, It's possible that thread T2 may print x=0.Why? because without any instruction to compiler e.g. synchronized or volatile, bExit=true might come before x=1 in compiler reordering. Also, x=1 might not become visible in Thread 2, so Thread 2 will load x=0. Now, how do you fix it?

 When I asked this question to a couple of programmers they answer differently, one suggests to make both threads synchronized on a common mutex, another one said make both variable volatile. Both are correct, as it will prevent reordering and guarantee visibility.

But the best answer is you just need to make bExit as volatile, then Thread 2 can only print “x=1”. x does not need to be volatile because x cannot be reordered to come after bExit=true when bExit is volatile.

What is difference between CyclicBarrier and CountDownLatch in Java
Relatively newer Java tricky question, only been introduced from Java 5. The main difference between both of them is that you can reuse CyclicBarrier even if Barrier is broken, but you can not reuse CountDownLatch in Java.

What is the difference between StringBuffer and StringBuilder in Java?
Classic Java questions which some people think tricky and some consider very easy. StringBuilder in Java was introduced in JDK 1.5 and the only difference between both of them is that StringBuffer methods e.g. length(), capacity() or append() are synchronized while corresponding methods in StringBuilder are not synchronized.

Because of this fundamental difference, concatenation of String using StringBuilder is faster than StringBuffer. Actually, it's considered the bad practice to use StringBuffer anymore, because, in almost 99% scenario, you perform string concatenation on the same thread.


Can you access a non-static variable in the static context?
Another tricky Java question from Java fundamentals. No, you can not access a non-static variable from the static context in Java. If you try, it will give compile time error. This is actually a common problem beginner in Java face when they try to access instance variable inside the main method. Because main is static in Java, and instance variables are non-static, you can not access instance variable inside main. See, why you can not access a non-static variable from static method to learn more about this tricky Java questions.

Questions for practice
  1. When doesn't Singleton remain Singleton in Java?
  2. is it possible to load a class by two ClassLoader?
  3. is it possible for equals() to return false, even if contents of two Objects are same?
  4. Why compareTo() should be consistent to equals() method in Java?
  5. When do Double and BigDecimal give different answers for equals() and compareTo() == 0. 
  6. How does "has before" apply to volatile work?
  7. Why is 0.1 * 3 != 0.3,
  8. Why is (Integer) 1 == (Integer) 1 but (Integer) 222 != (Integer) 222 and which command arguments change this.
  9. What happens when an exception is thrown by a Thread?
  10. Difference between notify() and notifyAll() call?
  11. Difference between System.exit() and System.halt() method?
  12. Does following code legal in Java? is it an example of method overloading or overriding?
  13. public String getDescription(Object obj){
       return obj.toString;
    }
    public String getDescription(String obj){
       return obj;
    }
    and
    public void getDescription(String obj){
       return obj;
    }


This was my list of Some of the most common tricky questions in Java. It's not a bad idea to prepare tricky Java question before appearing for any core Java or J2EE interview. One or two open-ended or tricky question is quite common in Java interviews.

lundi 22 août 2016

Les erreurs à ne pas faire en entretien

Je vais réagir un peu à chaud, suite à quelques entretiens catastrophiques que j’ai fait passer dernièrement. Je vous ai déjà parlé des entretiens d’embauche, mais là je vais être très directif, presque lapidaire.

Soyez ponctuel

L’entretien d’embauche, c’est LE moment où il faut séduire le recruteur. Si vous êtes en retard le jour où vous devriez être au top, à quoi s’attendre au bout du quatrième mois de boulot sur un projet difficile ? Vous arriverez tous les jours après 11 heures du matin ?
Prenez soin de noter les coordonnées téléphoniques que vous pourrez appeler en cas de problème.

Apportez plusieurs copies de votre C.V.

Si vous arrivez les mains dans les poches, qu’est-ce que ça peut donner comme indice quant à votre envie de décrocher le poste ?
Par pitié, au moment où on vous demande « Vous avez une copie de votre C.V. ? », ne répondez surtout pas « Il est disponible sur Internet, vous pouvez l’imprimer » ! Cela revient à dire que c’est au recruteur de prendre le temps que vous n’avez pas voulu prendre vous-même.
Le plus « amusant », c’est que bien souvent le gros problème n’est pas pour le recruteur, mais pour le pauvre candidat qui se retrouve à tenter de présenter son parcours sans le support de son curriculum.

Connaissez-vous vous-même

En tant que candidat, vous devez fournir à votre interlocuteur des raisons de vouloir vous embaucher. Pour cela, vous allez lui parler de vos études et des entreprises où vous avez travaillé, mais ça ne l’intéressera pas. Ce qu’il veut, c’est que vous lui expliquiez en détail ce que vous savez faire, ce que vous avez fait, et ce que vous avez envie de faire.
Détaillez le travail que vous avez réalisé durant vos précédentes expériences professionnelles et/ou vos projets d’étude. Expliquez les problèmes que vous avez rencontrés, les solutions que vous avez appliquées, ce que vous avez appris. Dites si vous avez travaillé tout seul ou au sein d’une équipe, et alors expliquez votre rôle.
Il y a 2 situations qui sont difficilement supportables :

  • Lorsqu’il faut tirer les vers du nez du candidat. Vous devez vous vendre. Au bout de la troisième fois que le recruteur vous demande de lui en dire plus, d’entrer dans le détail, de prouver votre savoir technique, quelque chose devrait faire « Tilt » dans votre tête. Inversez la tendance, prenez les devants : il vaut mieux que le recruteur vous demande de passer en vitesse sur certains aspects plutôt que de risquer de passer à côté de certaines informations qui pourraient être importantes.
  • Lorsque le candidat ne se souvient plus de ce qu’il a fait juste 2 ans auparavant. Un entretien, ça se prépare. Relisez votre CV au moins une fois, et prenez le temps de vous souvenir des détails importants – ceux qui méritent d’être racontés – de vos expériences. Si une ligne de votre CV est tellement peu intéressante que vous n’avez rien à raconter à son sujet, pourquoi y est-elle ?

Éteignez-moi ce ****** de téléphone portable

Si on a inventé le mode vibreur, ce n’est pas pour rien. Un téléphone qui sonne pendant un entretien, c’est désagréable. Quand il sonne une seconde fois, ça devient énervant. Quand c’est suivi par un SMS, ça devient un problème.
J’ai la politesse de couper mon téléphone au début de l’entretien, le minimum est que vous fassiez de même. Si par malheur vous n’y avez pas pensé, excusez-vous dès le premier appel, et éteignez aussitôt votre mobile. Ne prenez pas le risque qu’il sonne de nouveau (surtout si vous avez une sonnerie très rigolote mais complètement débile).
Et surtout, surtout, ne décrochez pas ! Ne rigolez pas, un candidat m’a déjà fait le coup pendant un entretien.

Renseignez-vous un minimum

Vous n’êtes pas un mercenaire de l’informatique ; si vous en êtes un, ce n’est pas l’image que vous devez donner (et ne m’envoyez pas de CV, merci). Si vous débarquez sans avoir la moindre idée de l’activité de l’entreprise dans laquelle vous postulez, vous risquez d’être catalogué comme une personne qui a l’habitude d’envoyer des centaines de CV à travers le pays. Comment s’intéresser à vous si vous ne semblez pas vous intéresser un minimum à l’endroit où vous allez peut-être travailler ?
Peut-être avez-vous fait des recherches, mais que celles-ci n’ont rien donné de concluant. N’hésitez pas alors à le dire !
De la même manière, si l’offre d’emploi ou la description de poste contenait des noms ou des acronymes que vous ne connaissez pas (nom de langage de programmation, de technologie, ou autre), prenez le temps de vous renseigner sur Internet. Dites ensuite au recruteur que vous ne connaissiez pas cette chose, mais que vous vous y êtes intéressé et que cela vous ouvre de nouvelles perspectives.
Par contre, ne faites pas l’erreur de dire que vous connaissez cette techno, juste après avoir lu sa définition sur Wikipedia. Soyez certain que le recruteur s’en rendra compte rapidement.

Maîtrisez-vous

Quand je fais passer un entretien, j’essaye de mettre le candidat à l’aise. Je sais que c’est un moment relativement stressant, et qu’il faut réduire ce stress si je veux pouvoir me faire une idée précise de la valeur du candidat. Mon but est de recruter une personne de qualité, pas de perdre mon temps en stressant les gens au point de leur faire perdre leurs moyens.
Malheureusement, certains candidats interprètent mal cette convivialité, et commencent à plaisanter comme si on était potes. Yeah, c’est super cool ! Mais bon, on en reparlera si tu es embauché, mon gars. En attendant, tu es gentil de surveiller ton langage et de rester concentré sur ton objectif. Ce n’est pas parce que tu n’es pas face à un costard-cravate d’une multinationale que tu peux te comporter fondamentalement différemment. Hum…
Prenez aussi garde à ne pas vous lancer dans de longs monologues sans laisser à votre interlocuteur la possibilité d’en placer une. Faites aussi attention à ne pas élever la voix plus que de raison ; cela arrive à beaucoup de personnes qui ont du mal à gérer leur nervosité, et c’est très désagréable (merci les maux de crâne à la fin de la journée).

mardi 24 mai 2016

Liens intéressants pour Cours et QCM Java

QCM : 

http://kitabxana.net/files/books/file/1354098917.pdf

http://pages.cs.wisc.edu/~hasti/cs368/JavaTutorial/NOTES/Exceptions.html

http://www.math.univ-paris13.fr/~chaussar/Teaching/2010-2011/IN120/corrige_test_final.pdfage Fundamentals

http://www.quizz.biz/quizz-417842.html


http://www.ukonline.be/programmation/java/exercices/qcm.php?id=9

http://jacques.laforgue.free.fr/SITE_NFA032/Examens/Site/2011-2012/CorrectionExamen2emeSessionNFA002_2011-2012.pdf

http://ensiwiki.ensimag.fr/index.php/QCM_APOO

Installation de Liferay

Environment: Windows, Tomcat Server and Liferay 6.2CE with Eclipse

Note:

I have used windows 7 operating system .You can apply the  same steps to any environment but the only change is  in setting the environment variables and downloading software’s based on OS. Remaining all are same for any operating system.

Required Steps

  1. Install JDK and setting required environment variables (JAVA_HOME, path)
  2. Download MySQL server and Start MySQL server
  3. Download HeidiSQL and install (Optional)
  4. Connecting to MySQL server and create Database for Liferay
  5. Download Liferay 6.2 Tomcat Bundles
  6. Download Liferay 6.2 Plugins SDK
  7. Download Liferay IDE with Eclipse
  8. Create Work space folder and Extract the downloaded files in work space directory.
  9. Change the name of tomcat liferay bundle to only bundles
  10. Configure database setting in portal-ext.properties file and place properties file in Liferay Home (bundles) directory.
  11. Configure Liferay Tomcat sever information in Plugins SDK properties file.
  12. Start Eclipse and configure liferay prospective
  13. Configure Plugins SDK in Eclipse
  14. Configure Liferay Tomcat Server in Eclipse
  15. Start Tomcat from Eclipse and access liferay portal
  16. Complete required basic configurations for liferay portal (This is only for first time)
  17. Start Liferay Application Development

Install JDK and setting required environment variables (JAVA_HOME, path)

We need to install JDK in our system and we need to set java path environment variables
Download java SDK 1.6 from following location and install JDK in your machine. Follow the installation steps when you install JDK.


Setting required environment variables
Go to your computer properties

Accessing System Environment variables from following screen.
Creating JAVA_HOME variable as follows
Variable Name: JAVA_HOME
Variable Value: The path where your java installed means JDK home directory

 The following screen shows you creating JAVA_HOME


Edit system path variable and specify the java path

In the existed system path variable add java path value (%JAVA_HOME%/bin)
In the System variables block you can see path variable, select path variable and click on edit button.


Add java path as follows

Once click on edit in variable value you can see existed path variable.
You can add   ;%JAVA_HONE%/bin;   to existed path value. Here each value is separated by semicolon.

This specify the java path which will used by java applications and servers.

The following diagram shows edit the system path variable

Download MySQL server and Start MySQL server

Download MySQL sever 5.1 from following location

  
Extract the zip file in your desired drive
Start MySQL database server
               Open command prompt and go MySQL bin directory (mysql-5.1.70-winx64/bin) then use following command to start MySQL database server
mysqld --console
Example:

The following is command prompt it start server and I am showing last line which indicate data base server started successfully.

Download HeidiSQL and install

Download HeidiSQL to access MySQL server databases. This is very good user interface to access database and modifies the data base tables.

Download HeidiSQL from following location


The following screen shows you download page of HeidiSQL
Double click on exe file and follow the installation steps to complete the successful installation.
HeidiSQL is data base browser we can manage database. Its very light weight and user friendly.
Connecting to MySQL server and create Database for Liferay

We can do this in two ways
  1.  Connecting MySQL from HeidiSQL and create Liferay Data base
  2.  Connecting to MySQL from MS DOS command prompt and create data base for liferay

Connecting MySQL from HeidiSQL and create Liferay Data base

Once successful installation of HeidiSQL, go to windows start and click on HeidiSQL
In Login window enter following details and connect to MySQL server
Click on New and enter the following details

Host Name:  127.0.0.1  OR  localhost
User: root
Password: nothing it’s empty

The following screen MySQL server login from HeidiSQL

Once you successfully login you can see databases view as follows

The following screen shows the HeidiSQL view

Create lportal database for Lifera portal. Right click on root node and select create new database
Enter database name lportal and click on Ok then database will be created
Connecting to MySQL from MS DOS command prompt and create data base for liferay

This is another way to connecting to MySQL server with windows command prompt
Open MS Dos command prompt from your system

Go to MySQL server bin directory from command prompt and enter following command and press enter

 It will ask password no need to enter password (because our password is empty) and again press enter

mysql -u root –p
The following screen shows you admin login into MySQL server
Now create data base using following command and press enter then loprtal data base will be created.

create database lportal;
Note:

Don’t forget semicolon end of the command

The following screen shows admin login in MySQL server and lportal database creation.
Download Liferay 6.2 Tomcat bundle

Download Liferay 6.2 Tomcat bundle from following location

The following screen is download page in website

Download Liferay 6.2 Plugins SDK

Download Plugins SDK from following location

Go to Liferay Portal 6.2 Community Edition section and from dropdown select Plugins SDK and download.

The following screen is Plugins SDK download page in liferay website.
Download Liferay IDE with Eclipse from following location




The following screen is Liferay IDE download page

or direct download :
 
64 Bits: 
https://sourceforge.net/projects/lportal/files/Liferay%20IDE/2.0.0%20GA1/liferay-ide-eclipse-windows-x64-2.0.0-ga1-201312200205.zip/download
 
32 Bits :
https://sourceforge.net/projects/lportal/files/Liferay%20IDE/2.0.0%20GA1/liferay-ide-eclipse-windows-x32-2.0.0-ga1-201312200205.zip/download

Create Liferay Work Space and copy all Zip files to this location

Create one directory in your system and name of directory is your choice.

Assume we have created Liferay Work Space in D drive (D: / Liferay Work Space)
Once all Zip files downloaded and place all files in Liferay Work Space folder and extract all zip files in same location (use extract here from WinZip or WinRAR)

We can see following files in Liferay Work Space after extraction of all ZIP files.

liferay-plugins-sdk-6.2.0,
 eclipse
liferay-portal-tomcat-6.2.0-ce-rc4
Note:

 Based downloaded versions some time folder name may be changed but we can easily identify the Liferay Portal and Plugins SDK.

The following screen shows all zip files and extract the zip files in same location


Change the name of Liferay Tomcat Bundles directory to only bundles

Once we extract the liferay 6.2 tomcat bundles change the name of directory to bundles this is only for development convenience.

Actual liferay 6.2 tomcat bundles name as follows

Now change the name to bundles

The following screen shows after change name to bundles.

Configure database setting in portal-ext.properties file and place properties file in Liferay Home (bundles) directory

Now bundles directory called as Liferay Home directory or we can say the directory which contains tomcat server is called Liferay Home directory .Inside bundles directory we can see tomcat server.

The files in bundles directory/Liferay Home as follows


Create one file called portal-ext.properties file in Lifeay Home/bundles Directory and add following MYSQL data base configurations.

    
jdbc.default.driverClassName=com.mysql.jdbc.Driver
jdbc.default.url=jdbc:mysql://localhost:3306/lportal?useUnicode=true&characterEncoding=UTF-8&useFastDateParsing=false
jdbc.default.username=root
jdbc.default.password=
Note:

Here our data base name is lportal already we created in previous step. You can create any database name of your choice but you need specify in portal-ext.properties file.

The following screen shows you portal-ext.properties file in Liferay Home directory


Configure Liferay server information in Plugins SDK properties file

Go to liferay-plugins-sdk-6.2.0 in the Liferay Work Space and copy build.properties file and past in same location (clone the build.propertis file).

The following screen is after clone the build.properties



And change the copied build.propertis file name to build.SystemUserName.properties

Example:

How to find system user?

Go to your windows installation directory and find Users directory and you can see all system users. We need current login user.

The following screen shows available user in system
Now find the current user and change copied build.properties file name to build.SystemUserName.properties

In my case my users name is E5410

So my properties file is build.E5410.properties

The following screen shows you system user name build properties file and build.properties file
Now open newly created build.SysteUserName.properties file in any editor and configure server information as follows.

Uncomment following line in the opened properties file (remove # symbol start of lines)

app.server.type=tomcat
app.server.parent.dir=${sdk.dir}/../bundles
app.server.tomcat.dir=${app.server.parent.dir}/tomcat-7.0.42
 app.server.tomcat.deploy.dir=${app.server.tomcat.dir}/webapps
 app.server.tomcat.lib.global.dir=${app.server.tomcat.dir}/lib/ext
 app.server.tomcat.portal.dir=${app.server.tomcat.dir}/webapps/ROOT
Make sure app.server.type and app.server.dir properties should be correct

Note:

By default Plugins SDK build.properties file configured to Tomcat server so we need not to change anything in build.SystemUserName.propertis(buil.E5410.properties) file when we use liferay tomcat bundle. Moreover configuration in properties file set to tomcat server so nothing we change in properties file but you can cross check the things as I said above.

The following is example for app server directory that is tomcat server which is in bundles directory.

Start Eclipse and configure liferay prospective

Go to eclipse directory and double click on eclipse.exe it will take few min for ready to available.

The following screen shows eclipse exe file in eclipse directory which in Liferay Work Space.
Once liferay started it will ask you the work space then select our Liferay Work Space directory (we already created this directory)

The following screen shows select the Work Space for eclipse

Once eclipse stared you can see Liferay IDE supported icons in eclipse because we already downloaded the eclipse which is integrated with liferay development support.

The following screen shows the liferay support icons.

Now change eclipse prospective to liferay

Click on add prospective icon and add liferay (which right side top corner)


Now we are in liferay prospective

The following screen showed us, we are in Liferay Prospective.

Configure liferay Plugins SDK to eclipse

Go to windows menu and click on preferences

Select Liferay in preferences and click on Installed Plugin SDKs

The following screen shows preferences window and Installed Plugin SDK

Now add your Plugins SDK directory (which is in Liferay Work Space folder)

Click on add button and browse liferay Plugins SDK which in Liferay Work Space and then click on ok button

The following screen shows configure the Plugins SDK


Once you browse the Plugins SDK and select never radio button and click on ok button then it will be finished.

Updating build properties file before SDK used, this you can make never so that it won’t ask you next time. Because we already done configuration in SystemUserName.build.properties file so we need not update for each time.

Now we configured Plugins SDK to eclipse. Now select the configured SDK and click on OK button. (We can configure many Plugins SDK to eclipse but we need check at least one to use in development)

The following screen showed us select the Plugins SDK.

Configure Liferay Tomcat Server in Eclipse

Now we need to configure tomcat server to eclipse

Go to windows preferences in eclipse and select servers and then click on Rune Time Environments as follows.



Add our liferay tomcat server (which is in bundles directory)

Click on add and select Liferay INC Tomcat7 select and click  check box(Create a new local server) then click on next.


Now browse tomcat server home location which is Liferay Work Space/bundles/tomcat7X

Note:

Tomcat Server Home directory nothing but in directory structure up to Tomacat7X folder (D:\Liferay Work Space\bundles\tomcat-7.0.40)

The following screen showed us tomcat home directory

Now select Run time JRE

Eclipse already has default JRE and Liferay Tomcat have another JRE apart from that we can also select our installed JRE (we already installed JDK/java in our system)
The following screen shows available JRE for tomcat server we can select any one or we can configure new JRE which is installed in system.


I suggest you select JDK or JRE which is installed in our system (Genaally you can see java installation in C:\Program Files\Java\jdk1.6.0_43 this called Java Home)

Click on installed JRE button and click on add button and select StandardVM and click on next.
Browse JDK (java installation directory) home directory (C:\Program Files\Java\jdk1.6.0_43), give any name for JRE Name text box (that’s your choice) and then click on finish


Now select our JRE from choices and click on ok then your eclipse and all configures servers use this JRE.


Now our configured JRE can see in dropdown list.

Select our JRE to liferay tomcat server as follows and click on finish button.


Select configured liferay tomcat server and click on OK

Now eclipse ready with Plugins SDK and Tomcat server for Liferay development

Once you finish all above steps then you can see eclipse in Liferay Prospective as follows.

We can different sections in eclipse.

Package explorer view:

 We can see all projects and its packages and files directory structure

Servers View:

 We can see all configured servers for eclipse now we already configure liferay tomcat servers. This you can see lifer side bottom.

Ant View:

Ant view used to display ANT build files of applications and we can run all ANT (compile, deploy) targets from this section. This you can see in top right.

Console View:

Console view for display server log information and build log information. This we can see middle bottom.

File Editor View:

This is used for edit file and writing code. We can see major section in middle.
Start Tomcat from Eclipse and access liferay portal
Go to eclipse servers view which you can see bottom left, there you can find Tomcat server. Right click on tomcat server and click on start.

Then server will be started. After few second it will show server started up message in console.

The following screen shows to start tomcat server in eclipse
In the eclipse console view you can see server startup message as follows.

The following screen shows tomcat server start up message it means server started successfully.
Access Liferay Portal

Use following URL in browser address bar to access liferay portal

Note:

Tomcat server default port is 8080 make sure no other application should not run in same port otherwise you can see address bind exception in console.
Complete required basic configurations for liferay portal (This only for first time)
After you access the liferay portal it will ask the some basic configuration details like administrator name, email, and password and remainder question.
You need accept some terms and conditions page then you finished the all steps
For complete detailed information you can go through following URL and read final step..