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

Creating a module using NetBeans

Now that you've learned how to create, compile, and execute a module using the Command Prompt, let's see how to do the same thing using the NetBeans IDE:

  1. Create a new project in the NetBeans IDE by clicking in the toolbar or, through the menu File | New Project, you'll see a New Project overlay with a new option in the Java category--Java Modular Project:
  1. Select that and click Next. In the next dialog, you can specify the name of your project (I chose addressbookviewer) and the location of your project and click Finish:
  1. Once the new project is loaded onto your IDE, you can right-click on the name of the project in the Projects tab and choose the option to create a new module:
  1. In the New Module dialog, enter the name of the module packt.addressbook and click Finish:

And just like that, you've created a new module! Note how NetBeans has automatically created the module descriptor for your module:

  1. Now what's left is to add the Main.java class by right-clicking on the module and going through the wizard:
  2. After adding the Main.java class, you can compile and execute it by right-clicking on the class and clicking Run File. You should see the message Hello World on the console panel at the bottom:

Congratulations! You've created, compiled, and executed your first Java module! This was a module with just one Java type, Main.java. Most of the code you'll be writing in this book will have you follow through the same steps that you just did. There will be several variations, of course, but we'll be examining the differences as we learn more about modules.

主站蜘蛛池模板: 永康市| 桓台县| 榆中县| 思南县| 临高县| 张家界市| 通化县| 太谷县| 报价| 长顺县| 屯门区| 尤溪县| 福鼎市| 莆田市| 焦作市| 县级市| 乌海市| 乌鲁木齐县| 扎囊县| 平江县| 新巴尔虎左旗| 东光县| 南漳县| 乌拉特中旗| 永修县| 平昌县| 盘山县| 庆云县| 十堰市| 肃南| 新昌县| 平远县| 叙永县| 米泉市| 阳朔县| 博兴县| 永州市| 绵阳市| 孝昌县| 石城县| 望都县|