File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Google language translation API Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Google language translation API" Watch "Google language translation API" New topic

Google language translation API

kandarp mehta

Joined: May 04, 2010
Posts: 6
I am using Google Transalation API to convert String from one language to another. I have already set Translate.setHttpHeader() value, then also it gives below exception.

java.lang.Exception: [google-api-translate-java] Error retrieving translation.
at com.nextenders.client.beans.ruleengine.RuleEngineTest.main(
Caused by: Connection timed out: connect
at Method)
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at<init>(Unknown Source)
at Source)
at Source)
at Source)
at Source)
at Source)
at Source)
... 2 more

Anybody know solution of this exception? Or anybody knows any API which convert from one language to another in java?
James Elsey
Ranch Hand

Joined: Dec 21, 2007
Posts: 228

Is there anything else in the stack trace?

I did a quick google on the exception your getting, a few of them have had a "caused by" then a URL, does your stack trace have that?

Have a look here, it is a quick tutorial and several people have posted regarding the error :

Also, it would probably be worth the investment to get the google API working, since their translation service is quite good. Maybe Yahoo or BabelFish provide something similar..

Kind Regards, James. OCPJP 1.6 || My SCJP / OCJCP Study Notes
Interested in : SCJP, Google App Engine, Stripes, Android;|| My Bite-Size SCJP Study Blog
Rob Spoor

Joined: Oct 27, 2005
Posts: 20269

kandarp mehta wrote:Caused by: Connection timed out: connect

You can't connect to the service, plain and simple. Try to find out to what host and port the service is trying to connect, then try connecting using telnet:
- open a Command Prompt
- type in "telnet HOST PORT" where HOST and PORT are the Google API host and port. For instance, "telnet 80" to test Google's website.

If you can also not connect this way then you should check your firewall, or contact your system administrator.

How To Ask Questions How To Answer Questions
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15081

You've also asked the same question on StackOverflow:

Please BeForthrightWhenCrossPostingToOtherSites

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
I agree. Here's the link:
subject: Google language translation API
jQuery in Action, 3rd edition