1
votes

Hi I am trying to restructure the package but with no luck. Suppose there are multiple packages in a project like:

main.java.com.wms.package1
main.java.com.wms.package2
main.java.com.wms.package3

I want to restructure it in the below format:

main.java
  com.wms.package1
  com.wms.package2
  com.wms.package3

Think of it this way there are 50 packages that start with main.java. So I want to make main.java as main package and the 50 packages under the main.java package How do I do this?

1
You don't. The 2 structures you're showing are exactly the sam just displayed differently. - Nicktar
Java file can have single package. Do you mean import statement? - Masudul
Main.java is not part of packagename i think. - Jens
There are java classes inside package 1 , it is referring to classes inside package 2 and package 3 by importing, but the classes inside packages are without main.java - Pramod Bhat
Like jens said main.java is not part of package name - Pramod Bhat

1 Answers

1
votes

one: "main.java" ist not part of the package names.

two: Although the path-like appearance of package names may trick you into thinking that, Java packages are not hierarchical. That means foo.bar is not a child of foo. If you want the list of packages to be displayed in a certain style, see if your IDE supports that style!

three: If your source files really contain the line package main.java... a refactoring should be considered. If that is not possible, follow option two!