Is there a way to create package-info.java for existing packages in one move in eclipse?

glee8e picture glee8e · Jul 4, 2016 · Viewed 11.8k times · Source

I have some legacy packages which doesn't have package-info.java. For some reason I need to create package-info.javas for them and I found the task really boring because there is no shortcut in eclipse for me to do that. I have to manually use the New > File procedure to create the file, then manually type in those package names.

Is there a shortcut in eclipse for such task?

Answer

Leo Izen picture Leo Izen · Jul 4, 2016

There is no easy way to do this as far as I know, at least "the right way."

What you can do as a shortcut is right-click package-info.java and click "Copy." Then you can use the keyboard shortcut to paste the package-info.java in any package. Eclipse automatically changes the package org.whatever.pkgname; command to match the package you paste the java file into.