使用maven编译protobuf需要的jar包
1.下载maven(编译工具)
进入maven官网http://maven.apache.org/ 下载maven(目前最高版本为apache-maven-3.0.4-bin.zip)
2.安装
解压apache-maven-3.0.4-bin.zip后,把bin目录添加到环境变量中
测试是否安装成功
3.编译
(1)把protoc.exe文件放入E:\protobuf-2.4.1\src中
(2)然后进入E:\apache-maven-3.0.4\bin目录,修改mvn.bat文件,
在@set MAVEN_OPTS=...下一行添加set MAVEN_OPTS=-Xmx512m -Xms128m
不添加有可能在编译时出现OutOfMemoryError错误:
[INFO] Processing DependencySet (output=portalserver)
[INFO] Expanding: C:\Documents and Settings\ThinkPad\.m2\repository\server\tomcat\5.5.23\tomcat-5.5.23.zip into C:\DOCUME~
hived-file-set.944161008.tmp
[INFO] Processing DependencySet (output=portalserver/shared/lib)
[INFO] Building zip: D:\portal\portalserver\application\target\swordportal-0.1-SNAPSHOT-server-tomcat.zip
[INFO] ------------------------------------------------------------------------
[ERROR] FATAL ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Java heap space
[INFO] ------------------------------------------------------------------------
[INFO] Trace
java.lang.OutOfMemoryError: Java heap space
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 32 seconds
[INFO] Finished at: Thu Nov 08 14:36:22 CST 2007
[INFO] Final Memory: 15M/63M(3)使用命令提示符进入E:\protobuf-2.4.1\java,执行命令mvn package
执行成功
在E:\protobuf-2.4.1\java\target目录下,就有我们所需要的jar包