MAC OSX: netbeans-8.2-javase-macosx.dmg
- Select File ⇾ New Project
- In the New Project window, select the Java category, and choose Java Application, then Next.
Next is the Name and Location dialog. Set the:
Project Name: HelloYou can stop there if you want, just observe the two other important settings which indicate exactly where and what is the project folder:
Project Location: Project Folder:NetBeans also pre-checks the box Create Main Class. You can uncheck it or leave it alone. Click Finish.
If Create Main class was checked, otherwise skip.
After creation you should be focused on the Projects window. If you kept the auto-created Main class, it will be displayed. For this course, you will only ever need this Projects window, and so you can close the others (you can always get them back from the Window menu). If you fully expand the Hello project (assuming you've kept the auto-created Main class), you'll see this structure:
Hello Source Packages (or src) hello Hello.java
For CSC142, we do not want to use the hello package, so right-click on hello, select Delete and complete with OK.
now have the following display in Projects:
Hello Source Packages (or src)
Right-click on default package and select:
New ( ⇾ Other ⇾ Java ) ⇾ Java Main ClassAfter you select Java Main Class once, it appears directly from New. Set the class name:
Class Name: HelloWorldClick Finish.
Go to the Files view and observe the structure which NetBeans creates. The src folder is meant to hold all the source packages. The HelloWorld.java file is in a package directory HelloWorld within the src folder.
Within the public static void main function, remove the TODO
- Select File → Save (or Ctrl-S) to save. In Netbeans, saving is compiling.
There are several ways to run this application. One way is to right-click on HelloWorld.java and select Run File from the popup menu. Look for the output in the Output window at the bottom.
NetBeans Projects on a flash driveYou can maintain one or more NetBeans projects on a flash drive, carry them around with you and work on them at different locations in which NetBeans is installed. Let's assume we're doing this on a Windows system for definiteness. Assume you've created a sample NetBeans project in the "usual" place, which would be in the Documents folder, more precisely:
C:\Users\LOGIN\Documents\NetBeansProjectsLet's use project Hello created in the first section. It is represented by the folder:
C:\Users\LOGIN\Documents\NetBeansProjects\HelloInsert your flash drive and open a folder which accesses the flash drive. Drag the Hello into the flash drive folder.