A
A
Alex vak2017-12-10 00:53:10
Java
Alex vak, 2017-12-10 00:53:10

How to deal with source not found in eclipse?

Hello. Now I decided to start learning java. I have win 8.1 64 bit. Installed JDK 1.8 SE 64 bit and Eclipse neon.3 for Java EE 64 bit. All possible paths in variable environments are registered.
When I run a case study, for example, a program that is a variation of the Java text-to-speech program.
`Main` class:

package com.example.TTS; // package of class Main
    
    import com.example.TTS.GoogleTextToSpeech; // import class GoogleTextToSpeech
    
    public class Main {
      
      public static void main(String[] args) {
        GoogleTextToSpeech gtts = new GoogleTextToSpeech(); // make instance gtts
        gtts.say("Hello dear friends", "en"); // use method say
    //  gtts.say("Bonjour mon amis!", "fr");
      }
    }

`GoogleTextToSpeech` class:
package com.example.TTS; // package of class GoogleTextToSpeech
    
    import java.io.InputStream; // import  classes from Java library
    import java.net.HttpURLConnection;
    import java.net.URL;
    import java.net.URLConnection;
    import java.net.URLEncoder;
    import javazoom.jl.player.Player; // import class from jl1.0.1.jar
    
    public class GoogleTextToSpeech {
      private static String ENCODING = "UTF-8"; //make constants and assign values to them
      private static String URL_BEGINNING = "http://translate.google.com/translate_tts?ie=";
      private static String URL_QUERY = "&q=";
      private static String URL_TL = "&tl=";
      private static String USER_AGENT_LITERAL = "User-Agent";
      private static String USER_AGENT = "Mozilla/4.7";
    
      public void say( String phrase, String lang ) {
        
        try {
          //Make full URL
          phrase=URLEncoder.encode(phrase, ENCODING); //assign value to variable with name 'phrase' by use method encode from class URLEncoder 
          String sURL = URL_BEGINNING + ENCODING + URL_TL + lang + URL_QUERY + phrase; //assign value to variable sURL 
              URL url = new URL(sURL); // make instance url with constructor
              
              //Create connection
              URLConnection urlConn = url.openConnection(); //assign value to variable urlConn 
              HttpURLConnection httpUrlConn = (HttpURLConnection) urlConn; //Declaring a httpUrlConn variable of type HttpURLConnection and assigning it a value to some variable urlConn (which is previously reduce to  HttpURLConnection)
              httpUrlConn.addRequestProperty(USER_AGENT_LITERAL, USER_AGENT);// use method 
              
              //Create stream
              InputStream mp3WebStream = urlConn.getInputStream();//create instance and assign it a value
              
              //Play stream
              Player plr = new Player(mp3WebStream); //create instance plr with constructor
              plr.play(); //use method
        }
          //use exception with name ex
          catch (Exception ex) { 
          ex.printStackTrace(); //use method
        }
      }
    }

And I have the following output (in the eclipse console):
java.io.IOException: Server returned HTTP response code: 503 for URL: http://ipv4.google.com/sorry/index?continue=http://translate.google.com/translate_tts%3Fie%3DUTF-8%26tl%3Den%26q%3DHello%2Bdear%2Bfriends&q=EgRbegWvGJ3FldEFIhkA8aeDS952qU94sbK8DAgP55pH8cbMicZdMgFy
  at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1894)
  at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
  at com.example.TTS.GoogleTextToSpeech.say(GoogleTextToSpeech.java:32)
  at com.example.TTS.Main.main(Main.java:9)

When I click on that I get the result: or when I click on that I get the same result: And in both cases it says:HttpURLConnection.java:1492
5a298910d9f4e879443990.png
HttpURLConnection.java:1894
JRE4png.png
public class sun.net.www.protocol.http.HttpURLConnection extends java.net.HttpURLConnection
they mean some other class from SUN (where could it come from?).
Although if you click + ctrl on any class in main.java или в GoogleTextToSpeech.java(including the class HttpURLConnection)
5a2c5a215becb955842999.png
eclipse opens the source of these classes in a new tab, only for some reason the tabs are called, for example, HttpURLConnection.classand not HttpURLConnection.java
5a2c5adfd49ba633542850.png
That is, eclipse for some reason cannot open some classes. How to fix it?
How can I see the source of these classes? That is, somewhere something needs to be registered?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2017-12-10
@zagayevskiy

It is not necessary to prescribe anything anywhere, why do you need the source codes of these classes at all? The error says Server returned HTTP response code: 503 for URL. Figure out what's wrong with the server, why it responds this way and you will be happy. You don’t need to get into the guts of the dignity classes for this, especially since now you won’t understand anything there.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question