Thank you so much for your reply. The GpxUi software successfully converted the Gcode file into .x3g file. Hope it will work on Makerbot replicator 2x.
I got the G-code file from Makerbot desktop. The reason why I wanted to convert the G-code file that I got from Makerbot desktop to .x3g file is that I made some modifications in the G-code file (to change the toolpath) in the text editor and I wanted to use the edited G-code file to print the part in Makerbot replicator 2x. As I cannot use the G-code file directly, I needed a G-code to .x3g converter.