i am making a web application in which user can paste some code...it will also have a drop down which will have list of all languages like java, c, c++
i want to auto detect which language the code is and auto select that language in the drop down.
or any other way i can achieve this ?
You will have to study basic programs for typical keywords of all the languages you are displaying in a drop-down in your application.
few examples of the basic keywords...
C/C++ -> include
Java -> import
Php -> <?php
Cobol -> Identification Division
FoxPro -> Set command