I am making a java implementation of onion routing. The routers in the path on decrypting the received data , are able to device their position in the circuit by knowing the length of the received data. Is it acceptable that routers know their position in the circuit?
This should not be acceptable, no. Tor does not leak information about circuit position in this way, and there's no need for it. Use an encryption scheme that doesn't change the size of the data you're transfering to prevent leaking this information.
Are you trying to write a compatible implementation of Tor in Java? If so, check out Tor's specification to make sure you have a chance.