protected long encodeJavaEnvelope(OutputStream objOut,
			RPCJavaEnvelope javEnv) throws IOException {
		if(log.isDebugEnabled()) log.debug("encodeJavaEnvelope");
		long byteSent = 0L;		
		writeShort(objOut, javEnv.getEnvelopeType());	
		byteSent +=2L;
		Object jarSrc = javEnv.getJarSource();
		if(log.isDebugEnabled()) log.debug("JarSource:{}", jarSrc);
		if(jarSrc==null){
			if(log.isDebugEnabled()) log.debug("JarSource:nil");
			writeInt(objOut, -1);
			byteSent +=4L;
		}else if(jarSrc instanceof byte[]){
			if(log.isDebugEnabled()) log.debug("JarSource:byte array");
			byte[] jarContent = (byte[]) jarSrc;			
			writeInt(objOut,jarContent.length);
			byteSent +=4L;
			objOut.write(jarContent);
			byteSent +=jarContent.length;
		}			
		byteSent += encodeString(objOut, javEnv.getClassName());		
		List<RPCObject> rpcObjs = javEnv.getRpcObjects();		
		byteSent += encodeRpcObjects(objOut, rpcObjs);			
		objOut.flush();
		if(log.isDebugEnabled()) log.debug("end of encodeJavaEnvelope");
		return byteSent;
	}