Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where to find protobuf.jar for using Google protocol buffers in Java?

I downloaded protobuf-2.5.0.tar.gz, extracted it, did the usual ./configure, make, make check, and make install. However, the file protobuf.jar which seems to be needed for using protocol buffers in Java does not seem to be part of what I downloaded. Worse, I cannot find this file anywhere. Please advise me how to proceed.

like image 493
Roger House Avatar asked Mar 30 '13 20:03

Roger House


4 Answers

You can add it as a Maven dependency:

<dependency>
    <groupId>com.google.protobuf</groupId>
    <artifactId>protobuf-java</artifactId>
    <version>2.5.0</version>
</dependency>

All dependency information is available at Maven Central, or just download the .jar file directly.

like image 138
matsev Avatar answered Oct 24 '22 01:10

matsev


To generate the protobuf.jar file, you need to do what Bruce Martin suggests, but you then need to do the following:

  1. Navigate into the src/main/java/com/google/protobuf directory
  2. Make a directory called bin
  3. Run the following command to build the .java files: $ javac -d bin *.java
  4. Navigate into the bin directory, and finally, run the following command to generate the protobuf.jar file: $ jar cvf protobuf.jar com/

Then, copy and paste the jar to wherever you need it.

like image 31
Phanto Avatar answered Oct 24 '22 01:10

Phanto


You can download ProtoBuf Jar from

Here

then you can put jar inside libs folder

and if want to get Protobuf repository from maven then add inside pom.xml file.

Hope it will help..

like image 8
Neha Shukla Avatar answered Oct 24 '22 02:10

Neha Shukla


The simple solution is that you should compile the jar by yourself.

  1. Download the src code from https://code.google.com/p/protobuf/downloads/list
  2. Unzip it and follow the instruction in README

Here is what you should do in Linux

./configure  
./make

You can install the protoc by run ./make install

Then you need the jar, let me assume you are on ubuntu

install maven first sudo apt-get install maven

Then follow the instruction in /java/README.txt

If you want the standard jar

mvn package

If you want the lite version

mvn package -P lite

Then you can find the jar in /java/target

like image 7
zhaocong Avatar answered Oct 24 '22 02:10

zhaocong