Google Protocol Buffers 2.3.0 for java 快速开始
来源:互联网 发布:车道线识别算法 编辑:程序博客网 时间:2024/06/16 14:04
Google Protocol Buffers 2.3.0 for java 快速开始
- 博客分类:
- Java
JavaGoogleUbuntuLinux数据结构
一、下载protobuf
去http://code.google.com/p/protobuf/downloads/list下载最新版本。有Linux和Windowst版本,因为本人用的Ubuntu,所以下载的是linux版本。
二、编译protocol buffer提供的命令行工具protoc
将下载后的文件protobuf-2.3.0.tar.gz解压到当解目录
- sundoctor@sundoctor:~/download$ tar zxvf protobuf-2.3.0.tar.gz
进入protobuf-2.3.0目录,按照目录下的README.txt文件说明进行编译安装
- sundoctor@sundoctor:~/download$ cd protobuf-2.3.0
- sundoctor@sundoctor:~/download/protobuf-2.3.0$ ./configure
- sundoctor@sundoctor:~/download/protobuf-2.3.0$ make
- sundoctor@sundoctor:~/download/protobuf-2.3.0$ make check
- sundoctor@sundoctor:~/download/protobuf-2.3.0$ sudo make install
在ubuntu下可以将sudo make install换成sudo checkinstall,这样会将打包成一个deb文件后再安装,其实在ubuntu中也可以跳过这一步,用源安装更简单
- sundoctor@sundoctor:~/download$ sudo apt-get install protobuf-compiler
三、生成基础类库
进入protobuf-2.3.0下的java目录,执行
- sundoctor@sundoctor:~/download/protobuf/protobuf-2.3.0/java$ protoc --java_out=src/main/java/ -I ../src ../src/google/protobuf/descriptor.proto
命令把源代码包中的descriptor.proto编译一下,生成一个类。
然后将java/src/main/java中的源代码,就是基础类库,以后项目必须使用这些基础类,当然你也可以将其打成jar包,以方便使用。
四、测试
用eclipse新建java project项目为protobufDemo
编写proto定义文件,本文采用protobuf-2.3.0自带例子,进入protobuf-2.3.0的examples目录下有一个addressbook.proto文件,执行
- sundoctor@sundoctor:~/download/protobuf/protobuf-2.3.0/examples$ protoc --java_out=./ addressbook.proto
生成例子源代码,代码位于com目录下。
将三、四步中的基础类库、例子源代码、AddPerson.java、ListPeople.java拷到protobufDemo项目即可运行ddPerson.java、ListPeople.java进行测试
- Google Protocol Buffers 2.3.0 for java 快速开始
- Google Protocol Buffers 2.3.0 for java 快速开始
- Protocol Buffers for Java
- google的protocol buffers 对象的序列化 for java
- Google Protocol Buffers Java实例
- Google Protocol Buffers Java实例
- Google Protocol Buffers 快速入门 文章收集
- Useful links for mastering Google Protocol Buffers
- Google protocol-buffers java版--简单使用
- (Google)Protocol Buffers概览
- Google Protocol Buffers详解
- Google Protocol Buffers
- Google Protocol Buffers安装
- GOOGLE PROTOCOL BUFFERS
- Google Protocol Buffers浅析
- Google protocol buffers 小结
- Google Protocol Buffers浅析
- Google Protocol Buffers 概述
- Cocoa Core Competencies 的Object creation 和IOS面试题示例:写一个NSString类的实现
- Linux下select函数实现的聊天服务器
- alloca、calloc、malloc、realloc、free
- mysql命令
- android开发 : 在Eclipse中向sdcard中导入文件
- Google Protocol Buffers 2.3.0 for java 快速开始
- 网络通信—协议详细解析 大致结构
- C++ 类的继承,基类中的构造函数是谁在调用?
- 解决Ubuntu下NVIDIA和Intel双显卡的问题!
- Codeforces Round #146 (Div. 2) B. Easy Number Challenge
- Codeforces Round #146 (Div. 2) C. LCM Challenge
- java 文本文件加密 文本文件解密
- 推荐一个活动:VMware vForum 2012 开发者盛会
- 【转】Windows SOCKET 缓存/缓冲区 相关了解 Windows NT和Windows 2000的套接字架构