Tuesday, January 27, 2015

Protocol Buffer

What is Protocol Buffer?
  • Protocol Buffer is a technology employed in serializing the Structured Data.
  • Based on Interface Description Language Methodology that describes the structure of some data and a program (here it is Protocol Buffer Compiler) that generates source code in various programming languages representing the structured data.
How to install Protocol Buffer Compiler?

  • Download https://developers.google.com/protocol-buffers/docs/downloads
  • Add an entry for the Path in  Environment Variable Settings for Proto Buff Compiler.
  • Check if ProtoBuffer is installed correctly by using the command protoc --version

Protocol Buffer Message
  • Protocol Buffer Schema is described in a .proto file.
  • Each Protocol Message is a logical piece of information described in Name-Value Pair.
  • Single .proto file might contain multiple proto messages.

option java_outer_classname="ProtoUser";
  message System{
     required string ram_size=1 [default="Hello World!"];

Numbers 1,2,3 are referred to as Tags. Tags are primarily used to to identify the specific field in the Binary Form.

Message Fields should be specified of one of the following
  • Required
  • Optional
  • Repeated
Note: Some engineers at Google have come to the conclusion that using required does more harm than good; they prefer to use only optionaland repeated. However, this view is not universal.

Geneartion of JAVA Stub from Message Schema

C:\Users\60006990>protoc --proto_path==C:\Users\60006990\Desktop --java_out=C:\U
sers\60006990\Desktop\ C:\Users\60006990\Desktop\data.proto

protoc: act as the compiler
proto_path: refers to the destination
java_out: referes to the source and destination

Eclipse SetUp:

Wednesday, January 14, 2015

Resolve between two different versions of JAVA in Windows

At times we end up having to test our legacy J2EE Applications in more than one Java environment where there arises a need to switch between different versions of Installed Java Editions.

we start up with this article assuming the readers have two different versions of JDK installed in their system.

Lets' set up the Environment Variable for the respective Versions of JDK

1. Set up the JAVA7_HOME Variable for Jdk 7

2. Set up the JAVA6_HOME Variable for Jdk 6

3. Set up the JAVA_HOME variable and set the value pointing to one the editions set above.

4. Insert a Path Variable as %JAVA_HOME%\bin and make sure it is inserted before %SystemRoot%\System32 (Normally java.exe resides in this path and we prevent the system from referring this path and look at the JAVA_HOME path instead)

 5. run java -version from cmd to check  the version of Java running in the system. In case if we want to switch onto another version update the JAVA_HOME value and restart cmd to check for running version