Home

Awesome

libtorrent4j

macOS Linux Windows Android Codacy Badge Codacy Badge Maven Central

A swig Java interface for libtorrent.

Features
Support for WebTorrenthttps://webtorrent.io
Sequential downloading
Torrents queueing and prioritizing
Torrent content selection and prioritizing
NAT-PMP and UPnP support
Fast resume support
HTTP proxies and basic authentication
IP filter
Torrents over SSL
lt_donthave extensionBEP 54
Magnet URI extension - specify indices to downloadBEP 53
BitTorrent Protocol v2BEP 52
DHT Infohash IndexingBEP 51
Tracker Protocol Extension: ScrapeBEP 48
Padding files and attributesBEP 47
Multiple-address operation for the DHTBEP 45
Storing arbitrary data in the DHTBEP 44
Read-only DHT NodesBEP 43
IPv6 extension for DHTBEP 32
uTorrent transport protocol (uTP)BEP 29
Private TorrentsBEP 27
Tracker Returns External IPBEP 24
Tracker Returns Compact Peer ListsBEP 23
Extension for Partial SeedsBEP 21
HTTP/FTP Seeding (GetRight-style)BEP 19
SuperseedingBEP 16
UDP Tracker ProtocolBEP 15
Local Service Discovery (LSD)BEP 14
Multitracker Metadata ExtensionBEP 12
Peer Exchange (PEX)BEP 11
Extension ProtocolBEP 10
Magnet linksBEP 9
IPv6 Tracker ExtensionBEP 7
Distributed hash table (DHT)BEP 5

Using

Download the latest JAR or get the dependency via Maven:

<dependency>
  <groupId>org.libtorrent4j</groupId>
  <artifactId>libtorrent4j</artifactId>
  <version>2.x.x</version>
</dependency>

or Gradle:

compile 'org.libtorrent4j:libtorrent4j:2.x.x'

If you use ProGuard to obfuscate/minify make sure to add the following statement

-keep class org.libtorrent4j.swig.libtorrent_jni {*;}

Note that there are multiple versions of libtorrent4j for different platforms:

libtorrent4j
libtorrent4j-android-<arch>
libtorrent4j-macos
libtorrent4j-linux
libtorrent4j-windows

These are all different artifacts, you need to select according to your architecture.

For examples look at demos and tests.

Architectures supported:

About stability

This library tracks libtorrent master branch. The branch is very stable, runs a lot of tests, and receives bug fixes quickly.

Android local builds

It's possible to build android binaries locally. The solution is docker based, you need to have Docker installed and running (see https://docs.docker.com/engine/install/).

Go to the folder swig/android-build and perform all the operations inside it.

1 - Build the docker image just one time (takes a long time):

docker build -t lt4j:latest .

2 - Select your architecture and run the build script, for example:

./build-arm.sh

3 - Collect the jars in build/libs at the root of the project. Repeat the step 2) for the desired architectures.

License

Licensed under the terms of the MIT license, available here.