Peer groups are formed as a collection of peers that have agreed upon a common set of services. The {@link net.jxta.peergroup.PeerGroup} interface presents the API of those services and encapsulates the group's identity and the local peer's identity in that group.

A group is instantiated on a peer by instantiating the group class specified by the group definition and initializing the resulting object with the parameters specified by the group definition.

A group may be, and often is, defined and instantiated within the context of another group referred to as its parent group. In that case an appropriate and initialized {@link net.jxta.peergroup.PeerGroup} object, that represents that group may be obtained from the parent group by using one of the parent's {@link net.jxta.peergroup.PeerGroup#newGroup newGroup} methods.

All peers start with instantiating one well known root group (which has no parent) known as the World Peer Group. It is created by calling {@link net.jxta.peergroup.PeerGroupFactory#newPlatform()}.

The World Peer Group has a limited set of functionality. Most peers chose to instantiate early on another well known group known as the Net Peer Group and to use it as the root of the other groups they create.

An object representing the Net Peer Group may be obtained from the {@link net.jxta.peergroup.PeerGroupFactory} by invoking the method {@link net.jxta.peergroup.PeerGroupFactory#newNetPeerGroup()}. This method invokes {@link net.jxta.peergroup.PeerGroupFactory#newPlatform()} automatically, so if an application wants to use the Net Peer Group as its root group, invoking {@link net.jxta.peergroup.PeerGroupFactory#newNetPeerGroup()} is all that is required.

All other groups should be created or instantiated within the context of already instantiated groups by using one of the {@link net.jxta.peergroup.PeerGroup#newGroup newGroup} methods.

It is possible to change the identity, name, and description of the group that {@link net.jxta.peergroup.PeerGroupFactory#newNetPeerGroup()} instantiates by setting the following properties in the file config.properties (all three must be specified for the setting to take effect):

The same result may be obtained by invoking the following {@link net.jxta.peergroup.PeerGroupFactory} static methods:

It is also possible to create arbitrary subgroups of the World Peer Group programatically by first starting the World Peer Group and applying one of the {@link net.jxta.peergroup.PeerGroup#newGroup newGroup} methods of the resulting PeerGroup object. An example of creating multiple infrastructure peer groups. {@link Multiple Infrastructure Group Tutorial} @see net.jxta.peergroup.PeerGroup @see net.jxta.peergroup.PeerGroupFactory @see net.jxta.protocol.PeerGroupAdvertisement @see net.jxta.protocol.PeerAdvertisement @see net.jxta.id.ID @see JXTA Protocols Specification : Peer Groups