0

我正在尝试使用 j2objc 工具将我的一些 Android 项目逻辑文件转换为 ObjectiveC 代码。

我的实际项目出现了很多类型错误,所以我试图至少转换 helloworld,例如:

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

}

这可以使用 完美编译javac,但是当我尝试在其上运行j2objc时,它会返回奇怪的错误:

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

这里有什么问题,最重要的是,我该怎么办?

编辑:

命令行如下:

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

环境:

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

(这是由 退回的/usr/libexec/java_home

4

1 回答 1

1

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.

于 2016-04-10T22:43:42.187 回答