Introduction
This repository contains Java implementation of the device detection specification.
Dependencies
For runtime dependencies, see our dependencies page. The tested versions page shows the JDK versions that we currently test against. The software may run fine against other versions, but additional caution should be applied.
Data
The Java API can either use our cloud service to get its data or it can use a local (on-premise) copy of the data.
Cloud
You will require resource keys to use the Cloud API, as described on our website. Get resource keys from our configurator, see our documentation on how to use this.
On-Premise
If you are using on-premise detection, a "Lite" version of the data required is packaged in this repository. It contains only a limited set of "essential" device detection properties.
You may want to license our complete data file containing all properties. Details of our licenses are available on our website.
If you want to use the lite file, you will need to install GitLFS, then:
Then, navigate to 'device-detection.hash.engine.on-premise/src/main/cxx/device-detection-cxx/device-detection-data' and execute:
Installation
Our latest release is available as compiled JARs on Maven - or you can compile from source as described below.
Maven
The 51Degrees Java Device Detection package is available on maven. Make sure to select the latest version.
This package includes the Cloud and on-premise APIs.
Build and Install from source
Device detection on-premise uses a native binary. (i.e. compiled from C code to target a specific platform/architecture) This section explains how to build this binary.
Pre-requisites
- Install C build tools:
- Windows:
- You will need either Visual Studio 2019 or the C++ Build Tools installed.
- Minimum platform toolset version is
v142
- Minimum Windows SDK version is
10.0.18362.0
- Minimum platform toolset version is
- Set the CMake command path in the PATH environment variable:
set PATH="[Visual Studio Installation Path]\[Visual Studio Version]\BuildTools\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\";PATH%
- You will need either Visual Studio 2019 or the C++ Build Tools installed.
- Linux:
- Debian / Ubuntu:
sudo apt-get install g++ make libatomic1 cmake
- RHEL / CentOS / Fedora:
sudo yum install cmake gcc-c++ libatomic
- Debian / Ubuntu:
- Windows:
- Maven version 3.8.4 or higher is recommended, and what is used for our own build.
- If you have not already done so, pull the git submodules that contain the native code:
git submodule update --init --recursive
Build steps
Batch script and Bash script are provided to support building native binaries on Windows and Linux/macOS. These scripts are implicitly called by the Maven build step.
On Windows, the Platform Toolset version and Windows 10 SDK version can be overwritten when running mvn
by adding following options:
-DplatformToolsetVersion=[ Platform Toolset Version ]
-DwindowsSDKVersion=[ Windows 10 SDK Version ]
This is not recommended unless absolutely necessary and should be used with caution.
Tests
You will need resource keys (see above) to complete the tests and run examples which include exercising the cloud API.
To verify the code:
For tests and examples that require a license key add the following option:
-DLicenseKey=[License Key]
Projects
- device-detection - This is the project to get all Device Detection capabilities.
- device-detection.hash.engine.on-premise - when you want to use local detection.
- device-detection.cloud - when you want to use our cloud detection.
- device-detection.shared - Shared classes.