- Modular Programming in Java 9
- Koushik Kothagal
- 281字
- 2021-07-02 18:38:21
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:
- 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:

- 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:

- 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:

- 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:

- Now what's left is to add the Main.java class by right-clicking on the module and going through the wizard:
- 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.
推薦閱讀
- Advanced Splunk
- 程序員面試白皮書
- C++面向對象程序設計(微課版)
- 動手玩轉Scratch3.0編程:人工智能科創教育指南
- 云原生Spring實戰
- Mastering Apache Maven 3
- Learning Vaadin 7(Second Edition)
- Hands-On Full Stack Development with Go
- 零基礎學Python網絡爬蟲案例實戰全流程詳解(入門與提高篇)
- 打開Go語言之門:入門、實戰與進階
- Hands-On JavaScript for Python Developers
- 石墨烯改性塑料
- ASP.NET Core and Angular 2
- 從零開始學算法:基于Python
- 每個人的Python:數學、算法和游戲編程訓練營