Creating and Scaffolding Your Project
When you open your IDE for the first time you’ll be greeted with a welcome screen, just uncheck the show at startup box, close it and you should see something like this:
Click File-> New Project
Select “Maven and Java Application” and click next.
Next you’ll have to give it a name and a location.
Artifact Id is going to be the name of the final build file. Java will produce a .jar file which stands for Java Archive. Jar files can be libraries or executables.
Group Id is basically like a namespace for your artifact. Say you and someone else both create a jar file with the same name. The GroupId will prevent a collision between the two files if they are both included as a library in another program. The general convention is com for commercial, org for non-profit, mil for military, gov for government, and edu for education. This is usually followed by the organization’s name and then the name of the program. If you are familiar with .NET or C++ you can think of this as an effective namespace for the file itself.
The Package name is the namespace of your classes. It will prevent collisions with all other Java classes. For example if you create a class named Optional, and you need to both use your class and the JDK class optional you can refer to them both in the same context as java.util.Optional and com.drakos.invaders.util.Optional.
If you end up with a name collision because Java has loaded two different classes with the same name and same package simultaneously, Java will use the first class called for all references and you will have some unexpected runtime results.
Finish and you should have a Java program staring at you!
Next, double click your pom.xml and set the properties: “maven.compiler.source” and “maven.compiler.target” both to 1.8.
Click the files tab and drill down into the folders of your project. Create a folder under src called test then create a folder under test named java.
Copy your package folders. (COPY, don’t move! You want a duplicate package tree in the test folder.)
When we build our code, the test and the main trees will be merged without us having to think about it but only for tests. Any code we write in the test tree will never be included in the actual final artifact.
Click back on the Projects tab and you will see that Netbeans has auto-detected the presence of the test tree and has included it in your hierarchy.