Kotlin-错误:找不到或加载主类_DefaultPackage [英] Kotlin - Error: Could not find or load main class _DefaultPackage

查看:939
本文介绍了Kotlin-错误:找不到或加载主类_DefaultPackage的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在这里遵循了Kotlin Eclipse教程: Eclipse Luna入门

I followed the Kotlin tutorial for eclipse here : Getting Started With Eclipse Luna

但是,我遇到了这个错误:

However, I'm running into this error:

Error: Could not find or load main class _DefaultPackage

有人知道解决这个问题吗?

Anyone who knows to get around this?

推荐答案

这是一个严重的错误( KT-10221 )自动生成插件版本0.4.0中的启动配置.它已在0.5.0中修复,因此建议的解决方法是更新插件.

This was a severe bug (KT-10221) in automatic generation of Launch Configuration in plugin version 0.4.0. It was fixed in 0.5.0 so the recommendend way to workaround is to update plugin.

问题的根源是该插件使用了一种旧的模式来为Kotlin编译器放弃的主要功能生成类的名称.

The source of the problem was that the plugin used an old pattern for generating name of the class for main function that had been abandoned by Kotlin compiler.

可以通过手动编辑启动配置( Eclipse菜单->运行->运行配置... )并更改主类字段来解决此问题. > Java应用程序组.如本教程中所述,如果该文件名为 hello.kt 而没有包指令,则更正后的字符串应为 HelloKt .

It's possible to workaround it by editing launch configuration (Eclipse Menu -> Run -> Run Configurations...) by hand and changing Main class field in Java Application group. If the file is named hello.kt with no package directive, as it is described in tutorial, than corrected string should be HelloKt.

如果文件名为 other.kt 且包为 my.tutorial 而不是 Main Class 的文件应包含 my.tutorial.HelloKt .您可以在 Package- 从Java调用Kotlin 页面的层级功能.

If file has name other.kt with package my.tutorial than the Main Class should contain my.tutorial.HelloKt. You can read more about it in the section Package-Level Functions of Calling Kotlin From Java page.

这篇关于Kotlin-错误:找不到或加载主类_DefaultPackage的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆