Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The usual way how Protocol Buffers work is:</p> <ul> <li>You define your protocol in a small <code>.proto</code> text file.</li> <li>You run the protobuf compiler on that file</li> <li>proto compiler generates source code in all the languages you need to serialize &amp; parse objects.</li> </ul> <p>The library you use in C# is special. It does not need that <code>.proto</code> file to start with. Instead you can create the protocol within your code by annotating classes (or whatever the terminology in C# is).</p> <p>In order to use your in-code-generated protocol from Java you need the <code>.proto</code> file since Java does not support that type of definition in code.</p> <p>You can either write the <code>.proto</code> file by hand or let the C# library generate it (see Marc Gravell's answer) - I would suggest you generate the file so you can't make mistakes in the definition.</p> <p>Once you have that file you run the protobuf compiler (<code>protoc</code>) <a href="http://code.google.com/p/protobuf/downloads/detail?name=protoc-2.5.0-win32.zip" rel="nofollow">(dowload)</a> on the <code>.proto</code> file and it will generate a <code>.java</code> file for you. That file has the <code>Person</code> class and everything required to serialize and parse.</p> <p>Now you include both <code>protobuf[version].jar</code> and the generated <code>.java</code> file in your project. The <code>.proto</code> file itself is not required in the project.</p> <p>Once you have done that simply use the generated code to parse the file:</p> <pre><code>Person person = Person.parseFrom(new FileInputStream(file)); </code></pre> <p>The only line of code that you write is that one above.</p> <p>More details about the Java integration is found in the official <a href="https://developers.google.com/protocol-buffers/docs/javatutorial" rel="nofollow">tutorial</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload