The allocation of 2 bytes to the ‘int’ data type in a 32-bit operating system

Is it ensured that an int in Java will consistently have a size of 32 bits and a long will have a size of 64 bits, regardless of whether the architecture is 32 or 64 bits? In compat mode, user-space (referring to the perspective of a 32-bit program) functions identically to a system in legacy mode (where everything is 32-bit).

is int has 2 bytes in 32 bit os

Size of an int is more compiler dependent rather than an operating system. A 32-bit OS can have an int of 4 bytes. It's actually depended what compiler you’re using. If you're using a good-old compiler than maybe your compiler outdates to the language standard as well as not supporting the correct value of data type space.
More specifically (if you have the right compiler installed on your native system), 32-bit/64-bit processor and OS => int data type has value of 4bytes or 32bits 
16-bit processor and OS (the truth is most of today’s OS not support 16bit processors, and have a plan to run 16bit application in today’s OS? Not possible out of the box. You will need an emulator to run these programs) => int data type has value of 2byte or 16bits.
Even you have a 64-bit processor and OS installed but the compiler is not accurate than it might be show int data type as 2bytes. 
You can test the defect, by using “sizeof()” operator in C/C++ programming language 

Frequently Asked Questions