A major issue for distributed computing systems is partitioning of the application and generating distributed code that can run correctly and efficiently on network machines. This paper introduced a new distributed code generation method using object level analysis, which is a key function of our Java Distributed code Generating and Computing platform (JDGC). Through a novel two-level object level analysis, the communication affinity metrics between runtime objects are extracted. These object-to-object affinity metrics are then used to automatically ports standard concurrent program for single machine to the form that runs on a distributed system. The contributions of this proposal are twofold. The object level analysis technique while motivated from our integrated system for object distribution, is nevertheless a general approach for extracting object-to-object communication affinity metrics and can be used in other contexts. The distributed code generation method releases the developers from any special programming considerations for distributed environment.