官术网_书友最值得收藏!

Setting up the project with Maven

To start the project, we will use the directory structure and pom.xml that was created by Maven itself when we started with the following command line:

    $ mvn archetype:generate

It created the directories, the pom.xml file, and an App.java file. Now, we will extend this project by creating new files. We will code the sorting algorithm first in the packt.java9.by.example.stringsort package:

When we create the new package in the IDE, the editor will automatically create the stringsort subdirectory under the already existing src/main/java/packt/java9/by/example directory:

Creating the new Sort class using the IDE will also automatically create a new file named Sort.java in this directory, and it will fill in the skeleton of the class:

package packt.java9.by.example.stringsort; 

public class Sort {
}

We will now have App.java containing the following code:

package packt.java9.by.example; 

public class App
{
public static void main( String[] args )
{
System.out.println( "Hello World!" );
}
}

Maven created it as a starting version. We will edit this file to provide a sample list that the sorting algorithm can sort. I recommend that you use the IDE to edit the file and also to compile and run the code. The IDE provides a shortcut menu to start the code and this is a bit easier than typing the command in Terminal. Generally, it is recommended that you get acquainted with the IDE features to save time avoiding repetitive tasks, such as typing terminal commands. Professional developers use the command line almost exclusively to test command-line features and use the IDE whenever it is possible.

主站蜘蛛池模板: 丹寨县| 高安市| 济源市| 昌江| 屏山县| 黑河市| 西乡县| 绵竹市| 汾阳市| 岗巴县| 宜丰县| 涪陵区| 清苑县| 莱西市| 大厂| 克拉玛依市| 鲁甸县| 尚志市| 卓尼县| 措勤县| 榆社县| 郎溪县| 淮滨县| 麟游县| 江都市| 咸宁市| 苏尼特右旗| 缙云县| 沈丘县| 永州市| 四川省| 赤水市| 丰顺县| 聊城市| 曲周县| 乐东| 丁青县| 黄平县| 叙永县| 东山县| 宜兰县|