Looking for a Java User Agent String Parser

22,440

Solution 1

Yet try a new library that is updated monthly and available in The Central Repository: http://uadetector.sourceforge.net/

It is another wrapper for user-agent-string.info, but with a much more solid and tested implementation compared to the other ones.

I'm working on a stable API 1.0 which I want to release at the end of this year. After the release of API 1.0 you don't have to recompile anything. You only switch the uadetector-resources.jar in your applications lib dir. The feature 'updated monthly' means, if you want an integration tested 'UAS data' file, for which you have the guarantee that it runs with the defined core, than this one fit your needs. But if you are not interested in updating a JAR (that is tested by me), then you can use the OnlineUserAgentStringParser with the risk, that the implementation doesn't fit to run with the automatically downloaded XML. I'm not interested in releasing more 'uadetector-core' bundles as needed, especially when the API in version 1.0 is released.

Another solution for a client might be that he maintains the 'UAS data' for it's own, when he works with the OnlineUserAgentStringParser and customize the properties file to set the right URL.

Solution 2

As far as I know (and why shouldn't I, it's one of the services company I used to work at provides with its products), detecting user agents when done properly is actually a good business in itself.

There are several free databases such as WURFL containing some rudimentary identification patterns for user agents but those mainly focus on for example mobile phones so in the end you may have to keep using the one you've made and just add the capability to import from/export to various related formats related to current state of user agent identification metadata.

If you're not going to steer away from desktop/PC world, you won't have much to worry about though since there's only four major layout engines out there with of course a set of versions with varying capabilities. The four big ones are the one in Trident in IE, Mozilla's Gecko, KDE's WebKit (at least in Safari and Chrome) and Opera's Presto.

Share:
22,440
Admin
Author by

Admin

Updated on May 16, 2020

Comments

  • Admin
    Admin about 4 years

    Does anyone know of a great library in java for parsing user agent strings? We have written a custom one, but this seems like a common problem for many people. I would guess there is a good library available somewhere.

    For example, the user agent string...

    "Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US) AppleWebKit/532.0 (KHTML, like Gecko) Chrome/3.0.195.21 Safari/532.0"

    ... cryptically announces the arrival of a Windows Vista PC using Chrome on our site.

    I've seen libraries in python and ruby. Anything in java out there?

  • Rup
    Rup about 12 years
    This appears to be another wrapper around the user-agent-string.info data. How does it compare to their own library? From your gravatar I'd guess that's your own project? I'm not sure 'updated monthly' is a feature, though - you're expecting your clients to recompile and re-release their applications monthly?
  • before
    before about 12 years
    @Rup Thank you for your feedback! I hope my explanation gives you more insights.
  • Mike Holler
    Mike Holler over 4 years
    This library hasn't been updated since 2014. mvnrepository.com/artifact/net.sf.uadetector/…