Membuat Kamus dan Penterjemah Menggunakan Java Memanfaatkan Google Translate


Java Programming

Java Programming

Peralatan yang dierlukan :

  1. Java Development Kit 1.6
  2. Google API Translate Java
  3. NetBeans IDE 6.9

Siapa yang tidak tahu Google Translate? Saat ini bagi orang yang sering membaca artikel luar negri dan tidak mengerti bahasanya, biasanya menggunakan Google Translate untuk menterjemahkannya 😀 Tidak perlu menginstall aplikasi apapun. Saat kita akan membaut kamus, apa yang menjadi kendala? Biasanya tidak ada kendala, namun ada hal yang membosankan, yaitu menambahkan kosa kata – kosa katanya 😀 Nah kalo begitu kenapa tidak memanfaatkan Google Translate saja ?

Google API Translate Java merupakan framework yang dapat kita gunakan untuk jembatan antara aplikasi kita dan Google Translate, dengan menggunakan Google API Translate Java, kita dapat dengan mudah membuat aplikasi kamus ataupun penterjemah menggunakanJava. Penggunaannyapun sangat sederhana dan mudah.

package khannedy.kamus;

import com.google.api.translate.Language;
import com.google.api.translate.Translate;

public class Main {

    public static void main(String[] args) throws Exception {
        Translate.setHttpReferrer("http://localhost/");

        String string = Translate.execute("saya cinta kamu", Language.INDONESIAN, Language.ENGLISH);

        System.out.println(string);
    }
}

Dibawah ini adalah contoh aplikasi penterjemah berbasis GUI :

Java Google Translate

Java Google Translate

Silahkan download project NetBeans-nya disini.

Iklan

20 pemikiran pada “Membuat Kamus dan Penterjemah Menggunakan Java Memanfaatkan Google Translate

  1. thank’s kang.. nie akan coba saya pelajari dari project yang ada.. ^-^
    cm saya sedikit bingung aja junit ini buat apa yach??

  2. kang.. project netbeans nya ku jalankan kok kembaliannya muncul eror
    15 Jul 10 13:40:43 khannedy.kamus.Form buttonTranslateActionPerformed
    SEVERE: null
    java.lang.Exception: [google-api-translate-java] Error retrieving translation.
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:123)
    at com.google.api.translate.Translate.execute(Translate.java:69)
    at khannedy.kamus.Form.buttonTranslateActionPerformed(Form.java:131)
    at khannedy.kamus.Form.access$000(Form.java:22)
    at khannedy.kamus.Form$1.actionPerformed(Form.java:75)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6038)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
    at java.awt.Component.processEvent(Component.java:5803)
    at java.awt.Container.processEvent(Container.java:2058)
    at java.awt.Component.dispatchEventImpl(Component.java:4410)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.java:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    Caused by: java.net.UnknownHostException: ajax.googleapis.com
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
    at sun.net.www.http.HttpClient.(HttpClient.java:233)
    at sun.net.www.http.HttpClient.New(HttpClient.java:306)
    at sun.net.www.http.HttpClient.New(HttpClient.java:323)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:788)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:729)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:654)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:832)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:107)
    … 29 more
    15 Jul 10 13:41:13 khannedy.kamus.Form buttonTranslateActionPerformed
    SEVERE: null
    java.lang.Exception: [google-api-translate-java] Error retrieving translation.
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:123)
    at com.google.api.translate.Translate.execute(Translate.java:69)
    at khannedy.kamus.Form.buttonTranslateActionPerformed(Form.java:131)
    at khannedy.kamus.Form.access$000(Form.java:22)
    at khannedy.kamus.Form$1.actionPerformed(Form.java:75)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
    at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236)
    at java.awt.Component.processMouseEvent(Component.java:6038)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
    at java.awt.Component.processEvent(Component.java:5803)
    at java.awt.Container.processEvent(Container.java:2058)
    at java.awt.Component.dispatchEventImpl(Component.java:4410)
    at java.awt.Container.dispatchEventImpl(Container.java:2116)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916)
    at java.awt.Container.dispatchEventImpl(Container.java:2102)
    at java.awt.Window.dispatchEventImpl(Window.java:2429)
    at java.awt.Component.dispatchEvent(Component.java:4240)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)
    Caused by: java.net.UnknownHostException: ajax.googleapis.com
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:177)
    at java.net.Socket.connect(Socket.java:519)
    at java.net.Socket.connect(Socket.java:469)
    at sun.net.NetworkClient.doConnect(NetworkClient.java:157)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)
    at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)
    at sun.net.www.http.HttpClient.(HttpClient.java:233)
    at sun.net.www.http.HttpClient.New(HttpClient.java:306)
    at sun.net.www.http.HttpClient.New(HttpClient.java:323)
    at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:788)
    at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:729)
    at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:654)
    at sun.net.www.protocol.http.HttpURLConnection.getOutputStream(HttpURLConnection.java:832)
    at com.google.api.GoogleAPI.retrieveJSON(GoogleAPI.java:107)
    … 29 more

    kok ga bisa baca data yang diinputkan dari teks nya kang???

  3. maaf mas eko sebelumnya.. project nya udah saya coba.. yang jadi masalah itu bila koneksi dilakukan dengan proxy keluar eror seperti yang di tuliskan di atas.. namun apabila saya menggunakan direct atau modem bisa digunakan..
    Apakah ada solusi bila koneksi menggunakan proxy dan tidak memberikan report eror seperti yang telah dicantumkan di atas?? mohon bantuannya.. terima kasih 🙂

  4. admin sya mw tanya.
    sya ada tugas untuk buat aplikasi kamus seperti google translate ini, tp dirancang untuk mobile.
    adakah caranya?
    minta bantuannya admin. mksh

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s