The default package '.' is not permitted by the Import-Package syntax

Peter picture Peter · Oct 28, 2015 · Viewed 10.7k times · Source

Trying to run @org.junit.Test with Intellij IDEA.

It's an OSGi bundle, when hit Run 'testMyTest'

Getting following exception:

Error:osgi: [b2b-bundle] 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

Could someone kindly share light on this exception?

Thanks, Peter

Answer

Hemant picture Hemant · Dec 22, 2015

You probably didn't place your class inside a package.

Add

package your_package_name;

at the top of your .java file and you should be good.

PS: Depending on your package name, you may need to move the file to some other location as well