1, install Maven
A. Download apache-maven-3.2.5, Link: http://mirrors.hust.edu.cn/apache//maven/maven-3/3.2.5/binaries/
B. Extract to the specified directory: (I use the directory is)/users/zhoufei/documents/tools/apache-maven-3.2.5
C. Open terminal, configure environment variables:
VI ~/.bash_profile
maven_home=/users/zhoufei/documents/tools/apache-maven-3.2.5//maven Extract Directory
Export path= $PATH: $MAVEN _home/bin
Export Java_home=/library/java/javavirtualmachines/1.6.0.jdk/contents/home//jave Environment location
Note: 1.6.0.JDK is the version number of your current system installation
Make an edit effective: source ~/.bash_profile
D. Check if the installation is successful
Mvn-v
2, download Probuf source code and compiler
1. Download protobuf-2.5.0, Link: http://pan.baidu.com/s/1pJlZubT
2. Installation
Use the TAR-ZXF protobuf-2.5.0.tar.gz command to extract the source is protobuf-2.5.0,
CD protobuf-2.5.0 into the catalogue
If you wish to compile successfully after the output directory is/users/zhoufei/documents/tools/protobuf/, enter the following two commands:
./configure--prefix=/users/zhoufei/documents/tools/protobuf/
Make && make install
Successful compilation will export path=/users/zhoufei/documents/tools/protobuf/bin: $PATH added to the environment variable
Finally enter the Protoc--version command, such as display Libprotoc 2.5.0 the installation succeeds
3, example Test
Everything is ready, let's test it out.
Enter the directory:/users/zhoufei/documents/tools/protobuffile
VI Person.proto
Simply create a. proto file by pressing the grammar rules of Protocolbuffer
Package csdnblog;
Message Pbuser {
Required String userId = 1;
Optional string nick = 2;
Optional string avatar = 3;
}
Once created, we will compile this Person.proto file. The command is as follows:
Protoc--plugin=/usr/local/bin/protoc Person.proto--java_out=./
Protoc automatically looks for a plugin named "Protoc" in the/usr/local/bin/directory and compiles the. proto file using the plugin, resulting in the final file:
Person.java
Once this step is passed, it means that the protocobuffer can work properly.
Reference article:
Download and installation links for protobuf-2.5.0.tar.gz: http://blog.csdn.net/huguoping830623/article/details/45482725
Protobuf Detailed Links: http://mikewang.blog.51cto.com/3826268/1432136/
PROTOBUF Java Version installation steps