简体   繁体   中英

This can be caused by compile errors in Eclipse

When compiling a project in idea IDE, error occurs: Error:osgi: [Test] The default package '.' is not permitted by the Import-Package syntax. This can be caused by compile errors in Eclipse because Eclipse creates valid class files regardless of compile errors. The following package(s) import from the default package null

But when using Eclipse ide, it works. I've googled times, only found this post , but it's not my case. I de-compiled the produced class by OSGI, there's no class has syntax like import . Any idea for this problem?

在此处输入图片说明

Can you change package of your classes? That way eclipse will create new classes after compilation. Having '.' package is not good practice anyway.

Also, prefer different workspace for eclipse and intellij. Having 3 folders is good practice, one for source, one for eclipse workspace, one for intelliJ workspace. Each IDE creates their own files

I got this error due to a Groovy script file that had import statements, but no package name at the start of the file. I added a package name to my Groovy script, ran a clean to erase my target directory , and then the problem went away.

See answer by Hemant in this similar issue

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM