How to deal with the source not found in Eclipse?

Hello. Now decided to start learning java. I have wine 8.1 64 bit. Installed 1.8 SE JDK 64 bit and Eclipse neon.3 for Java EE 64 bit. All possible paths in the variable environments are registered.

When I perform the case study, for example, a program that is a variation of the program text-to-speech on Java.

The `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 the say method
 // 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 from the encode method of the 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 with the url constructor

 //Create connection
 URLConnection urlConn = url.openConnection(); //assign value to variable urlConn 
 HttpURLConnection httpUrlConn = (HttpURLConnection) urlConn; //httpUrlConn Declaring a 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
 Mp3WebStream InputStream = urlConn.getInputStream();//create instance and assign it a value

 //Play stream
 Player plr = new Player(mp3WebStream); //create instance with constructor plr
 plr.play(); //use method
}
 //use exception with name ex
 catch (Exception ex) { 
 ex.printStackTrace(); //use method
}
}
 }

And have the following output ( in 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 the HttpURLConnection.java:1492
I get the result:

5a298910d9f4e879443990.png

or when you click on the HttpURLConnection.java:1894
you get the same result: JRE4png.png

And in both cases, he writes:
public class sun.net.www.protocol.http.HttpURLConnection extends java.net.HttpURLConnection
those has in mind some other class from SUN (how could he I have?).

Although if you click+ctrl on any class main.java or GoogleTextToSpeech.java (including the class HttpURLConnection )

5a2c5a215becb955842999.png

Eclipse opens the source code for these classes in a new tab, but for some reason the tabs are called,for example, HttpURLConnection.classand not HttpURLConnection.java

5a2c5adfd49ba633542850.png

That is why eclipse can't access some classes. How to fix it?

How can I see the source code for these classes? That is, somewhere something to register?
June 10th 19 at 16:35
1 answer
June 10th 19 at 16:37
It is not necessary to register anywhere anything, why did you have the source code for these classes? The error says Server returned HTTP response code: 503 for URL. See what server why he's so responsible and you will have happiness. To climb this guts San classes do not need, especially since now there's nothing you do not understand.
It is not that I want to understand what is written in the sun classes and that I want to understand how Eclipse works and why the sources of some of the classes it opens and others do not. And why it opens the source code of the classes on the tabs of the extension class, not with the extension java. And where in my code do draw classes from the sun? - Cassandra.Schmeler commented on June 10th 19 at 16:40
because of these classes in the form of source (.java) you have no - Art_Christians commented on June 10th 19 at 16:43
well surely there is a solution somewhere, for example, grepcode eclipse plugin or something, tell me pliz. And where in my code do draw classes from the sun? - Cassandra.Schmeler commented on June 10th 19 at 16:46
,
And where in my code do draw classes from the sun?

because it's part of JVM which was developed by SUN..
or do you think HttpURLConnection is full of magical object out of thin air? it's part of the JVM
===
In General, if we are so interested, install the JDK with sources - aliya.Miller82 commented on June 10th 19 at 16:49
, JDK and so I have c source, that's why I can see the source code of classes5a2c60949d7d8889615370.png

But he's talking about
public class sun.net.www.protocol.http.HttpURLConnection extends java.net.HttpURLConnection
(he shows me), and not
abstract public class HttpURLConnection extends URLConnection
(which I seen in my prog)

5a2c613ff33fe888972232.png - Cassandra.Schmeler commented on June 10th 19 at 16:52
, https://stackoverflow.com/a/45656875
In other words, this thing is platform specific and it is dependent on the JRE. - Art_Christians commented on June 10th 19 at 16:55
those sources I can't see? How it got into my program? I because it did not use sun classes? Already knew. - Cassandra.Schmeler commented on June 10th 19 at 16:58
,
But he's talking about

not


He rightly says, you understand the difference between abstract class and normal? - aliya.Miller82 commented on June 10th 19 at 17:01
but I do not understand how it can be done differently (without sun) or to defeat THOSE errors (caused by sun)? - Cassandra.Schmeler commented on June 10th 19 at 17:04
, if you want, I can probably find source code, but why? You get class features: when you call openConnection(), because an instance of the abstract class can not exist, and here is its implementation. - Art_Christians commented on June 10th 19 at 17:07
know , but briefly and rapidly to clarify - you will not prompt where it can be done? - Cassandra.Schmeler commented on June 10th 19 at 17:10
why you want to do it without sun? I already mentioned the answer - the problem is not in Sanaa, and that the server replies to you 503. TTS out of place here, you make a normal HTTP request and the server responds with error. - Art_Christians commented on June 10th 19 at 17:13
and where should I dig to my prog zarobotat? - Cassandra.Schmeler commented on June 10th 19 at 17:16
, it is necessary to dig in the direction of the 503 response from the server, you most likely misunderstood the request is sent
"transport" classes like URLConnection is not to blame here, you are wrong to use the API of Google - aliya.Miller82 commented on June 10th 19 at 17:19
the third time I repeat - to dig aside "why the server responds with a 503". - Art_Christians commented on June 10th 19 at 17:22
tell me also, please. when I look source code classes in eclipse, I use source configuation: C:/Program Files/Java/jdk1.8.0_152/src.zipand is it possible to download from Internet a zip/jar file containing complete contents of the source? - Cassandra.Schmeler commented on June 10th 19 at 17:25
those I have not properly specified a list of constants:

private static String ENCODING = "UTF-8"; // create the constants
 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";


Is it possible to use another API (what) - I want this app to work.

I found the class description of sun.net.www.protocol.http.HttpURLConnection it is located here and here. - Cassandra.Schmeler commented on June 10th 19 at 17:28
not asked this question, usually there is no need to climb so deep.
Here is the answer about the Google TTS. https://stackoverflow.com/a/31791632 - Art_Christians commented on June 10th 19 at 17:31
and in General in your experience for a similar program (like me) need to use google TTS or , for example, yandex TTS or some other? - Cassandra.Schmeler commented on June 10th 19 at 17:34
I don't understand the meaning of the program, TTS for TTS? Any what can get. Yandex is a good Doc in Russian https://tech.yandex.ru/speechkit/cloud/ - Art_Christians commented on June 10th 19 at 17:37
thanks for the advice, please tell me, and in these tabs I need something to configure?

5a2d5938a8e1a546253486.png5a2d5941e4e19812331707.png - Cassandra.Schmeler commented on June 10th 19 at 17:40
here's what to prescribe necessary (and whether it can affect rabotosposobnosti my program)?

5a2d5a2b9cb2a983831895.png - Cassandra.Schmeler commented on June 10th 19 at 17:43
no - Art_Christians commented on June 10th 19 at 17:46

Find more questions by tags WindowsJavaEclipse