使用Eclipse IDE在同一项目中的Kotlin和Java

使用Eclipse IDE在同一项目中的Kotlin和Java

问题描述:

我发布了有关gradle的类似问题,但是这个问题没有gradle或maven.

I posted a similar question regarding gradle but this question is without gradle or maven.

我无法使用Eclipse IDE使Kotlin正常工作.使用IntelliJ可以很好地工作,但是许多开发人员仍然使用Eclipse.我已经安装了Kotlin Eclipse插件,但无法正常工作.我已经下载了Kotlin标准库和运行时库,并将它们添加到项目中.还是行不通.当我拥有Java和Kotlin时,我所碰到的所有东西都无法解析为指定的类型.

I can not get Kotlin working properly using Eclipse IDE. This works great using IntelliJ, however many developers still use Eclipse. I have installed the Kotlin Eclipse plugin and does not work. I have downloaded the Kotlin standard library and runtime library and added them into the project. Still not working. All I get in eclipse when I have Java and Kotlin is cannot be resolve to a specified type.

我不使用Maven或Gradle,因为我无法同时使用它和这两个.

I'm not using maven or gradle because I couldn't get it working with those two either.

如果我在同一源文件夹中混合使用Java和Kotlin,则会收到此错误. 类型错误.NonExistentClass无法解决.它是从所需的.class文件中间接引用的".

If I mix Java and Kotlin in the same source folder I get this error. "The type error.NonExistentClass cannot be resolved. It is indirectly referenced from required .class files"

我正在使用Eclipse Neon.如果有人可以帮助我,那真是太好了,我现在已经尝试了很长时间,却一无所获. :(

I'm using Eclipse Neon. If anyone can help me that would be awesome, I've been trying for quite some time now and not getting anywhere. :(

添加Kotlin Nature可解决此问题.单击您的项目并配置 Kotlin->添加Kotlin性质

Add Kotlin Nature fixes the issue. Click on your project and Configure Kotlin -> Add Kotlin nature

尽管eclipse插件仍然存在问题,并且自动导入功能对我仍然无效,但这部分解决了该问题.

This partially fixes the issue, though eclipse plugin is still buggy and auto import function still doesn't work for me.

如果遇到任何问题,请确保在项目中添加了kotlin_bin文件夹.还要确保所有kotlin文件都具有正确的程序包名称,有时在重命名程序包或在kotlin类周围移动文件时可能不会更新.

If you're having any issue, make sure you have kotlin_bin folder added in your project. Also make sure that ALL kotlin files have the correct package name sometimes when you rename packages or move files around kotlin classes may not get updated.