- About Scala
- Documentation
- Code Examples
- Software
- Scala Developers
Eclipse 3.5 mixed Scala/Java: errors in Java editor but still compiles?
Fri, 2009-07-17, 18:04
Hi - I'm starting to work Scala into a large Java project and just
doing some basic tests. I just did a fresh install of Eclipse 3.5 and
the 2.7.5.final Scala plugin (on Ubuntu 9.04 with Java 1.6.0.14). I
created a new Scala project and then created a Scala object and a Java
class as follows:
package com.pongr.mixedtest
object MyObject {
def get() = "from scala object"
}
package com.pongr.mixedtest;
public class Test {
public static void main(String[] args) {
System.out.println(MyObject$.MODULE$.get());
}
}
Eclipse compiles everything just fine and running Test prints "from
scala object" to the console, as expected. But in the Eclipse editor
for Test.java, the MyObject$.MODULE$ part is red-underlined with the
error "MyObject$.MODULE$ cannot be resolved".
This isn't a deal-breaker since everything still compiles & runs but
it is slightly annoying to see the error in the Java editor. Can I
tweak the Eclipse install somehow to get rid of these types of error
messages in the Java editor? Or do I just need to leave comments in
the code like "ignore the cannot be resolved error on the next line"?
Thanks,
Zach