How do I use Digi's XBee Java Library with the XBee in API 2 (Escaped mode)?

Product family: XBP24-ZB
Function set: ZigBee Coordinator API
Firmware version: 21A7

Hello, I am currently using Digi’s XBee Java Library with API (AP=1) and it works properly.
However, another node of my network is associated with an Arduino and I want to use ‘Arduino Library for communicating with XBee in API mode’ (
That Arduino Library requires API Escaped operating mode (API 2). It was not supposed to be a problem, since XBee Java Library supports API 2. Nevertheless, I got an error when trying to open the serial connection with the XBee.

>> Error
com.digi.xbee.api.exceptions.TimeoutException: There was a timeout while executing the requested operation.
at com.digi.xbee.api.AbstractXBeeDevice.sendXBeePacket(
at com.digi.xbee.api.AbstractXBeeDevice.sendATCommand(
at com.digi.xbee.api.AbstractXBeeDevice.sendParameter(
at com.digi.xbee.api.AbstractXBeeDevice.getParameter(
at com.digi.xbee.api.AbstractXBeeDevice.readDeviceInfo(
at com.digi.xbee.example.MainApp.main(

Is there any difference between API and API 2 when programming with this Java Library?

have you looked through the documentation that is prvoided at

Thanks for your reply! I looked, but it always says that this library supports API 2. I looked at the source code of the library and it does work with API 2, but I can not identify the reason of the problem.

Eclipse indicates the error in the following function of the library source code (line indicated as a comment):

protected XBeePacket sendXBeePacket(final XBeePacket packet) 
			throws InvalidOperatingModeException, TimeoutException, IOException {
		// Check if the packet to send is null.
		if (packet == null)
			throw new NullPointerException("XBee packet cannot be null.");
		// Check connection.
		if (!connectionInterface.isOpen())
			throw new InterfaceNotOpenException();
		OperatingMode operatingMode = getOperatingMode();
		switch (operatingMode) {
		case AT:
		case UNKNOWN:
			throw new InvalidOperatingModeException(operatingMode);
		case API:
		case API_ESCAPE:
			// Build response container.
			ArrayList responseList = new ArrayList();
			// If the packet does not need frame ID, send it async. and return null.
			if (packet instanceof XBeeAPIPacket) {
				if (!((XBeeAPIPacket)packet).needsAPIFrameID()) {
					return null;
			} else {
				return null;
			// Add the required frame ID to the packet if necessary.
			// Generate a packet received listener for the packet to be sent.
			IPacketReceiveListener packetReceiveListener = createPacketReceivedListener(packet, responseList);
			// Add the packet listener to the data reader.
			// Write the packet data.
			try {
				// Wait for response or timeout.
				synchronized (responseList) {
					try {
					} catch (InterruptedException e) {}
				// After the wait check if we received any response, if not throw timeout exception.
				if (responseList.size() < 1)
					throw new TimeoutException();//ERROR INDICATED IN THIS LINE!
				// Return the received packet.
				return responseList.get(0);
			} finally {
				// Always remove the packet listener from the list.