When reengineering a monolithic application to be a distributed one, programmers always have to decide how many distributed parts the application should be partitioned, and write many codes related to where a part will be placed on network nodes and how these parts communicate with each other through the network. These codes usually have nothing to do with the business functions of the application, and they are laborious to write. In addition, as the distribution architecture of the application is finalized beforehand, it may not adapt well to the everchanging execution environment. In this paper, we propose DPartner, an automatic partitioning system, to help programmers create a distributed Java application without explicitly writing the distribution-related codes. Unlike the other partitioning systems, DPartner does not partition an application directly into the coarse-grained client and server. Instead, it first partitions the application into several modules where each module performs a relatively independent business function of the application. Then it makes these modules be distributable through automatic bytecode rewriting. These modules can distribute in different nodes and cooperate to work just as the original monolithic application. Such a module-based partitioning approach enables a relatively easy reshaping of the distribution architecture of an application, which facilitates the application adapt to the environmental changes without manual recoding or repartitioning with regard to distribution. This paper gives the detailed design of DPartner, and evaluates it using real-world applications. The evaluation results demonstrate the effectiveness and efficiency of DPartner.