Difference between revisions of "Setup Aplikasi Project di NetBeans"
Jump to navigation
Jump to search
Onnowpurbo (talk | contribs) (New page: ==Pranala Menarik== * Java Menggunakan NetBeans * Pemrograman Java * Linux Howto) |
Onnowpurbo (talk | contribs) |
||
Line 1: | Line 1: | ||
+ | ==Membuat Java Class Library Project== | ||
+ | 1. Choose File > New Project (Ctrl-Shift-N). Under Categories, select Java. Under Projects, select Java Class Library. Click Next. | ||
+ | 2. Under Project Name, type MyLib. Change the Project Location to any directory on your computer. From now on, this tutorial refers to this directory as NetBeans_projects. | ||
+ | Note: The path specified above should appear as follows in the Project Folder field of the wizard: /NetBeans_projects/MyLib/ | ||
+ | 3. (Optional) Select the Use Dedicated Folder for Storing Libraries checkbox and specify the location for the libraries folder. See Sharing Project Libraries for more information on this option. | ||
+ | 4. Click Finish. The MyLib project opens in both the Projects window and the Files window. | ||
+ | |||
+ | |||
+ | |||
+ | ==Membuat Java Application Project== | ||
+ | |||
+ | |||
+ | 1. Choose File > New Project. Under Categories, select Java. Under Projects, select Java Application. Click Next. | ||
+ | 2. Under Project Name, type MyApp. Make sure the Project Location is set to NetBeans_projects. | ||
+ | 3. (Optional) Check the Use Dedicated Folder for Storing Libraries checkbox. | ||
+ | 4. Enter acrostic.Main as the main class. | ||
+ | 5. Ensure that the Set as Main Project and Create Main Class checkboxes are checked. | ||
+ | 6. Click Finish. The MyApp project is displayed in the Project window and Main.java opens in the Source Editor. | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | ==Konfigurasi Classpath untuk Kompilasi== | ||
+ | |||
+ | |||
+ | Since MyApp is going to depend on a class in MyLib, you have to add MyLib to the classpath of MyApp. Doing so also ensures that classes in the MyApp project can refer to classes in the MyLib project without causing compilation errors. In addition, this enables you to use code completion in the MyApp project to fill in code based on the MyLib project. In the IDE, the classpath is visually represented by the Libraries node. | ||
+ | |||
+ | To add the library's utility classes to the project classpath: | ||
+ | |||
+ | 1. In the Projects window, right-click the Libraries node for the MyApp project and choose Add Project as shown in the image below. | ||
+ | |||
+ | Image showing the Add Project command that is offered when you right-click a project's node. | ||
+ | 2. Browse to NetBeans_projects/ and select the MyLib project folder. The Project JAR Files pane shows the JAR files that can be added to the project. Notice that a JAR file for MyLib is listed even though you have not actually built the JAR file yet. This JAR file will get built when you build and run the MyApp project. | ||
+ | 3. Click Add Project JAR Files. | ||
+ | 4. Expand the Libraries node. The MyLib project's JAR file is added to the MyApp project's classpath. | ||
Revision as of 11:00, 27 May 2009
Membuat Java Class Library Project
1. Choose File > New Project (Ctrl-Shift-N). Under Categories, select Java. Under Projects, select Java Class Library. Click Next. 2. Under Project Name, type MyLib. Change the Project Location to any directory on your computer. From now on, this tutorial refers to this directory as NetBeans_projects.
Note: The path specified above should appear as follows in the Project Folder field of the wizard: /NetBeans_projects/MyLib/ 3. (Optional) Select the Use Dedicated Folder for Storing Libraries checkbox and specify the location for the libraries folder. See Sharing Project Libraries for more information on this option. 4. Click Finish. The MyLib project opens in both the Projects window and the Files window.
Membuat Java Application Project
1. Choose File > New Project. Under Categories, select Java. Under Projects, select Java Application. Click Next. 2. Under Project Name, type MyApp. Make sure the Project Location is set to NetBeans_projects. 3. (Optional) Check the Use Dedicated Folder for Storing Libraries checkbox. 4. Enter acrostic.Main as the main class. 5. Ensure that the Set as Main Project and Create Main Class checkboxes are checked. 6. Click Finish. The MyApp project is displayed in the Project window and Main.java opens in the Source Editor.
Konfigurasi Classpath untuk Kompilasi
Since MyApp is going to depend on a class in MyLib, you have to add MyLib to the classpath of MyApp. Doing so also ensures that classes in the MyApp project can refer to classes in the MyLib project without causing compilation errors. In addition, this enables you to use code completion in the MyApp project to fill in code based on the MyLib project. In the IDE, the classpath is visually represented by the Libraries node.
To add the library's utility classes to the project classpath:
1. In the Projects window, right-click the Libraries node for the MyApp project and choose Add Project as shown in the image below.
Image showing the Add Project command that is offered when you right-click a project's node. 2. Browse to NetBeans_projects/ and select the MyLib project folder. The Project JAR Files pane shows the JAR files that can be added to the project. Notice that a JAR file for MyLib is listed even though you have not actually built the JAR file yet. This JAR file will get built when you build and run the MyApp project. 3. Click Add Project JAR Files. 4. Expand the Libraries node. The MyLib project's JAR file is added to the MyApp project's classpath.