简体   繁体   中英

New Java project structure Help needed

I am not so aware of the java project structure. I have few selenium tests which I want to write in java. So I have chosen eclipse as my editor. Here I wan to create a new java project with proper folder structure as I am planning to add few more java classes in future.

Please let me know how to create an idea java project in eclipse. I have seen people create something like com.org.project_name etc and then src , resources directories inside that.

I am not able to make any sense out of those. Please explain.

The software project management tool Apache Maven recommends, uses and expects a common directory layout that can be considered as best practise .

An overview can be found here: Introduction to the Standard Directory Layout

Eclipse应该为您创建合适的文件夹...这里有一个示例http://www.wikihow.com/Create-a-New-Java-Project-in-Eclipse

If you want to have a Java Project then go to File -> New -> Java Project.

If its web application then, select Dynamic Web Project.

These will automatically create the required structures.

在此处输入图片说明

In Java you work in packages, which define the scope of your classes, and is basically the only thing you should really be concentrating on in the beginning. There's a good article on the subject here - http://docs.oracle.com/javase/tutorial/java/package/packages.html

In Java you can create packages. Simply said packages are folders that contain classes.

The statement import java.net.Socket means: from the folder java/net import the class named Socket .

The statement package myApplication.util.SuperCounter means that the class SuperCounter can be found under myApplication/util folder.

Packages are an easy way to organize your work. Because in a big project you will have class name collisions (ie classes that use the same name). With packages you can avoid it.

Also Java supports default (private, public, protected). Default methods, attributes, classes can only be seen by elements in the same package!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM