My code compiles fine in Eclipse, but when I try to compile from the commandline (via our ruby-based buildr system), I get this error message:
static import only from classes and interfaces
Suggesting that static import of public static fields is not permitted. What should I look for to help diagnose this problem? How can I fix it?
Update: per @Ted's request, the constant declaration in the referenced file:
public static final String NULL = "<NULL>";
and the (bowdlerized) reference in the referring file:
import static my.path.MyClass.NULL;
In my case, I have two packages in VSCode and I was importing a method from a different package in another package class.
You can see it in the pics attached.
Now this import statement
is working fine in IntelliJ idea as it is an IDE, but VSCode uses CLI so we need to do this.
Go to your root directory (in my case it was
Object-oriented_Programming
) and then run these commands:This is just an example: you need to write the path of your directory and file.
The cause of error was that because of this import statement we need to include the path of this import on compile time, which was missing.