I would like to know What are the difference between folder-structure and package used in Eclipse IDE for Java EE development.
When do we use which one and why?.
Whats should be the practice
which option would be better and easy to deploy if i have to write a ant script later for deployment ?
if i go for the folder-structure will the deployment is as easy as copying files from development to deployment target ?
Packages are self-contained Project Files. Everything you need for your Project is saved inside the Package. Which makes it easy to share. Folders are slightly more transparent and accessible.
The difference is the Build Path: whatever folder is under the build path is a JAVA package. If your build path is /src/main/java then src, main, java are folders. If inside /src/main/java , your app is structured like this com/foo/bar/Main. java, then com, foo and bar are packages.
A Java package is like a directory in a file system. In fact, on the disk a package is a directory. All Java source and class files of classes belonging to the same package are located in the same directory. Java packages can contain subpackages.
Folder Structure of Java Projects. When you create a Java project, Application Platform creates a folder structure that contains the following folder types: Source Folders. The source folders contain the Java source files and unit test source code.
If you configured stuffs correctly. Adding a folder inside src
, is same as adding a package from File > New Package
.
So, it's up to you, whatever feels comfortable to you -- add a folder or create a package. Also, when you put stuffs under src
the package name starts from subfolder. So, src/com/naishe/test
will be package com.naishe.test
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With