Get the current latitude and longitude of the user in Java


I see this question asked a lot here for Java, but every single one I see seems to be Android-centered: I need a way of getting the user's current latitude and longitude when they call is coming from a computer, not a mobile device. I know that this is doable in C#, but I'm not sure how exactly to do it in Java. I've used Google Maps' restful API before: however, it wants an address as input, and I just want to get the user's current lat/lon, which I feel is simpler than making a call to Google. Any help would be greatly appreciated.

Java doesn't currently provide a general platform-independent API to get location. However, there may be platform-specific ways.

Most implementations on a desktop machine will geolocate via IP address; you can use these services from Java (Best way to get geo-location in Java). However, if operating systems provide a more general API, it can take advantage of any GPS hardware.

For Mac OS,

There's detail here of a Gnome-provided library, and also a write-up of plans for support in KDE.