Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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

like image 948
Peter Avatar asked Oct 28 '15 15:10

Peter


People also ask

Which is the default package import in Java?

For convenience, the Java compiler automatically imports two entire packages for each source file: (1) the java. lang package and (2) the current package (the package for the current file).

What is the syntax used when you will import a certain class only?

Import the Specific Class If we use import packagename. classname statement then only the class with name classname in the package will be available for use.

Which is default package in Java files?

Java compiler imports java. lang package internally by default. It provides the fundamental classes that are necessary to design a basic Java program.

What is the default package in Java Eclipse?

The default package is a collection of java classes whose source files do not contain and package declarations.


1 Answers

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

like image 100
Hemant Avatar answered Sep 21 '22 18:09

Hemant