I'm developing for a project which is compiled for Java 7.
In this project I use OkHttpClient v3.12.13, which is compatible for Java 7 (as stated here). However these lines produces an error in the Eclipse editor:
private static final OkHttpClient GLOBAL_OK_HTTP_CLIENT = new OkHttpClient.Builder()
.readTimeout(10, TimeUnit.SECONDS)
.build();
The error is this:
The type java.time.Duration cannot be resolved. It is indirectly referenced from required .class files
This error is only shown by the editor. Indeed, when I compile my project using CLI (outside Eclipse) I don't get any error for that implicit reference to the java.time
package.
I'm aware that in Java 7 there is no java.time
package. Indeed, I'm not using it in my code, it's just implicitly referenced by the OkHttp library (as the error message says).
Is there a way to fix this error on Eclipse?
This is how I configured compiler compliance on Eclipse:
Note that I can't upgrade to newer Java versions.
question from:
https://stackoverflow.com/questions/66067782/the-type-java-time-duration-cannot-be-resolved-when-using-okhttpclient-v3-12-x-o 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…