When I compile this code:
StringBuilder sb = new StringBuilder();
sb.append("a");
I get this error:
Error: The type java.lang.CharSequence cannot be resolved. It is indirectly referenced from required .class files.
Does anyone know how to fix it?
And, I use Eclipse compiler A0.48, becouse JDK 8.0 compiler don't want to compile.
The error message is generated by the Eclipse compiler for reasons I do not
understand. I recommend downloading either a Java 6 or Java 7 JDK. I
defined the following class
class Sample {
public String foo;
public Sample() {
StringBuilder sb = new StringBuilder();
sb.append("a");
foo = sb.toString();
}
}
I successfully compiled this class (and created an instance in the DrJava
interactions pane) using compiler in Java 7, Java 6, and Java 5.
Compilation with Java 8 failed because DrJava passes the argument -target
"1.7" to the compiler which is not compatible with the Java 8 compiler
processing Java 8 source code. I will fix this problem, but I defer
addressing the strange behavior of the Eclipse compiler. The error is
either a problem in the Eclipse compiler or a library compatibility issue
that is best solved by bunding a different open source compiler with
DrJava Almost noone uses the Eclipse compiler; we included it in DrJava to
enable users to run Drjava using a JRE installation (which has no Java
compiler). The inclusion predates the open-JDK versions of Java, so we
should replace the Eclipse compiler by an open-JDK compiler. I will
eventually make this change.
Best,
Corky Cartwright
On Tue, Jan 28, 2014 at 1:29 PM, RastaBillySkank rastabillyskank@users.sf.net wrote:
Related
Bugs: #944
Hello Mr. Cartwright,
I just encountered this problem with some students who ran your updated (Java 8)
version of DrJava (from the Rice page) without the JDK, but using JRE 8. If they have the JDK, it doesn't cause a problem. The bug is in the eclipse compiler. I was able to fix it by just downloading the latest (Luna) eclipse core batch compiler (ecj-4.4.jar) from the Eclipse downloads page: http://download.eclipse.org/eclipse/downloads/drops4/R-4.4-201406061215/
I was then able to update the DrJava.jar by opening it in 7Zip, deleting the eclipse folder inside org, and dragging and dropping the eclipse folder from inside ecj-4.4.jar. Once I did that, your test program shown compiled and ran with all 4 compilers (6, 7, 8, ecj) even when using the Java 8 runtime.
--Steve