Give Feedback for the page

JavaFeatures Matrix for PubNub Java V4 SDK


These docs are for PubNub 4.0 for Java which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.0 for Java and PubNub 3.0 for Android.

If you have questions about the PubNub for Java SDK, please contact us at

Access ManagerAccess ManagerPubNub provides builtin enterprise-grade security with fine-grained access control to all of your PubNub applications with PubNub Access Manager, Message Layer encryption with AES256, and Transport Layer Security with TLS and SSL.

GrantThis function establishes access permissions for PubNub Access Manager (PAM) by setting the read or write attributes.

Channel GroupsChannel GroupsChannel Groups allows PubNub developers to bundle thousands of channels into a group that can be identified by name. These Channel Groups can then be subscribed to, receiving data from the many backend-channels the channel group contains.

Add ChannelsAdd channel to a channel group.
List Channels In Channel GroupList all channels of a channel group.
Remove ChannelsRemove channel from channel group.
Remove Channels GroupsRemove channel groups.

Mobile PushMobile PushPubNub's Mobile Push Gateway feature enables developers to bridge native PubNub publishing with 3rd-party push notification services including Google Android GCM (Google Cloud Messaging), Apple iOS APNS (Apple Push Notification Service), and Microsoft Windows Phone MPNS (Microsoft Push Notification Service).

Add Device To ChannelsEnables push notifications on provided set of channels.
List Channels From DeviceList all channels on which push notification has been enabled.
Remove DeviceDisable push notifications from all channels which is registered.
Remove Device From ChannelsDisable push notifications on provided set of channels.

NotifyNotifyAlerts from the SDK

Request message count exceededWhen the number of messages arrived on a subscribe response are equal to or greater the number set in the init config, a new status message on the status callback, with the category PNRequestMessageCountExceededCategory, will be invoked.

PresencePresencePubNub's Channel Presence empowers your applications to Track online and offline status of users and devices in realtime.

Get StateGet state is used to get the key/value pairs specific to a subscriber uuid.
HeartbeatTimeout events are triggered when the server does not hear a hearbeat from the client within a default timeout time of 280 seconds.
Here NowObtain information about the current state of a channel including a list of unique user-ids currently subscribed to the channel and the total occupancy count of the channel.
Set StateSet state is used to set key/value pairs specific to a subscriber uuid.
Where NowObtain information about the current list of a channels to which a uuid is subscribed to.

PublishPublishPublish a message on a channel.

FireFire method used for publishing. When a message is sent using fire, it will not be replicated to other Points of Presence, it will remain at the originating Point of Presence, and is not eligible for archiving via the Storage and Playback feature.
Publish AsynchronouslyPublish the message asynchronously.
Publish RAW JSONPublish JSON as is.
Publish using GETPublish using HTTP GET
Publish using POSTPublish using HTTP POST
Publish with MetadataPublish extra meta with the request used for Message Filtering.
Replication FlagControls whether the message should be replicated across stores.
Store FlagAbility to skip message from storage.
TTL per published messageOffer the ability to set a per message time to live in storage.

StorageStoragePubNub's Storage and Playback feature enables developers to store messages as they are published, and retrieve them at a later time.

CountSpecifies the number of historical messages to return.
Include TimetokenWhether event dates time tokens should be included in response or not.
ReverseTraverse the timeline in reverse starting with the oldest message first.
Start EndTime token delimiting the start/end of time slice (exclusive) to pull messages from.

SubscribeSubscribeThis function causes the client to create an open TCP socket to the PubNub Real-Time Network and begin listening for messages on a specified channel.

Filter ExpressionStream Filter allows a subscriber to apply a filter to only receive messages that satisfy the conditions of the filter. The message filter is set by the subscribing client(s) but it is applied on the server side thus preventing unwanted messages (those that do not meet the conditions of the filter) from reaching the subscriber.
Publisher UUIDHas the publisher UUID of the published message.
Subscribe to channel groupsAbility to subscribe to channel groups.
Subscribe to channelsAbility to subscribe to channels.
Subscribe to presence channel groupsAbility to subscribe to presence channel groups.
Subscribe to presence channelsAbility to subscribe to presence channels.
Subscribe with timetokenSubscribe with timetoken.
Wildcard subscribeWildcard subscribes allow the client to subscribe to multiple channels using wildcard. E.g., if you subscribe to a.* you will get all messages for a.b, a.c, a.x. The wildcarded * portion refers to any portion of the channel string name after the dot (.).

TimeTimeReturn a 17 digit precision Unix epoch from the server.

TimeThis function will return a 17 digit precision Unix epoch from the server.
Check out PubNub's other Java-based SDKs, such as Java V4, Android V4