Thrift: language independent communication of Android to Linux box

Overview

This document describes programming language-independent, e.g.:

  • Java to C++, 
  • Java to Python, 
  • Java to Java 
communication between Android and Linux server (i.e. Mac, Raspberry Pi, BeagleBone Black).

Installing Thrift Compiler

On Debian Linux:
apt-get install thrift-compiler

On Mac:

$ brew install thrift
==> Installing thrift dependency: boost...==>
Summary /usr/local/Cellar/thrift/0.9.1: 89 files, 4.8M, built in 2.8 minutes

Creating Thrift Definition File


namespace java com.company.project.thrift
service MyService {
    bool enableMethod();
    bool disableMethod();
}

Generate Sources from Thrift Definition File

$ thrift --gen java -out gen ./src/main/thrift/definition_file.thrift

This line tells Thrift
  • --gen java - generate Java files (change for C++, etc.)
  • -out gen - put output files in "gen" folder
  • ./src... .thrift - use this definition file


As an Amazon Associate I earn from qualifying purchases.

My favorite quotations..


“A man should be able to change a diaper, plan an invasion, butcher a hog, conn a ship, design a building, write a sonnet, balance accounts, build a wall, set a bone, comfort the dying, take orders, give orders, cooperate, act alone, solve equations, analyze a new problem, pitch manure, program a computer, cook a tasty meal, fight efficiently, die gallantly. Specialization is for insects.”  by Robert A. Heinlein

"We are but habits and memories we chose to carry along." ~ Uki D. Lucas


Popular Recent Articles