Calculating distance between two points, using latitude longitude?

I am trying to calculate distance between two points using java code, I have written a code but it is not working. I have checked various forums to get the resolution to my query. I have found [java questions and answers][1] specifically posted on this forum and hope I’ll get a solution from the member of this community.

Here is code

final double RADIUS = 6371.01;
double temp = Math.cos(Math.toRadians(latA))
* Math.cos(Math.toRadians(latB))
* Math.cos(Math.toRadians((latB) - (latA)))
+ Math.sin(Math.toRadians(latA))
* Math.sin(Math.toRadians(latB));
return temp * RADIUS * Math.PI / 180;


hi findnerd2

is 6371.01 is radius of earth then convert it to meter bcoz it is in km
and also you are not using longitude anywhere i think this link would help you

there is java script code so just replace “var” with “double” you will get java code :slight_smile: if you have any trouble while writing java code then ask me i will help you out.