Search code examples
javamacosj2objc

"Object can not be resolved to a type"


I'm trying to convert some of my Android project logic files into objectiveC code with j2objc tool.

I get a lot of type errors with my actual project, so I'm trying to convert at least helloworld, e.g.:

public class Test {
    public static void main(String args[]) {
        System.out.println("Hello");
    }

}

This can be compiled perfectly using javac, however when I try to run j2objc on it, it returns bizzare errors:

The type java.lang.Object can not be resolved. It is indirectly referenced from required .class files.

What is the issue here, and most importantly, what should I do with this?

Edit:

Command line as follows:

j2objc -sourcepath src/main/java src/main/java/org/takino/mtga/impl/datatypes/*java

Environment:

JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_77.jdk/Contents/Home

(this was returned by /usr/libexec/java_home)


Solution

  • Go through the steps on the Getting Started page, which is similar to what you are already doing. You shouldn't have too much trouble, as Linux and OS X aren't that different to use from the command-line, since bash is the default shell for both.

    @chrylis has a good point about paths, since the j2objc script specifies the associated lib/jre_emul.jar as the bootclasspath to use, which is where all the JRE classes are (including Object). Perhaps your j2objc distribution got messed up.

    Try downloading the j2objc distribution again, unzip it but don't move any files around. Then use the /j2objc command, which will find the correct jre_emul.jar.