You are trying to access data from a different domain than it is hosted on, which is in violation of the Same-Origin Policy. In essence, this is a security measure taken to prevent cross-site scripting attacks.
Therefore, you cannot make requests to a different domain unless it supports CORS. If you look in your browser console, you should see this error:
XMLHttpRequest cannot load http://www.google.com/finance/getprices?q=.NSEI&x=NSE&i=60&p=1d&f=d,%20o,%20h,%20l,%20c,%20v. Origin http://example.com is not allowed by Access-Control-Allow-Origin.
There are ways around it, but that is most certainly the reason why you can access the data in Java and not in JavaScript.