Search code examples
javaintellij-ideaversionjava-6java-5

Mix Java 5.0 and Java 6.0 Code


I have one module developed under java 5.0

package mypack;

class MessageParser {
    public MessageParser(String s) {
    ......
    }
}

I have another module developed under java 6.0

import mypack;
......
String str = someString;
MessageParser parser = new MessageParser(str);
......

But I got the error "cannot find symbol constructor MessageParser(java.lang.String)"

BTW: the IDE I am using is intellij idea

Could anyone tell me why and how to get it work?


Solution

  • This has little to do with Java5-6.

    Probably you have a different version in your classpath.

    Double check what jar/file you're using in your Java 6 code, and triple check it correspond to the one you're seeing in you Java 5 version. Mostlikely you're seeing an old version which didn't have the constructor.