Σχόλια 0

Το κείμενο του εγγράφου

09/10/12 19:44testwww: NetBeans IDE 6.7 Java Quick Start TutorialPágina 1 de 6http://testwww.netbeans.org/kb/docs/java/quickstart.htmlNetBeans IDE Java Quick Start TutorialWelcome to NetBeans IDE!This tutorial provides a very simple and quick introduction to the NetBeans IDE workflow by walking you through thecreation of asimple "Hello World" Java console application. Once you are done with this tutorial, you will have a generalknowledge of howto create and run applications in the IDE.This tutorial takes less than 10 minutes to complete.After you finish this tutorial, you can move on to the learning trails,which are linked from theDocumentation, Training &Supportpage.The learning trails provide comprehensive tutorials that highlight a wider range ofIDE features andprogramming techniques for a variety of application types. If you do not want to do a "Hello World" application,you canskip this tutorial and jump straight to the learning trails.ContentsSetting Up the ProjectAdding Code to the Generated Source FileCompiling and Running the ApplicationBuilding and Deploying the ApplicationNext StepsTo complete this tutorial, you need the following software and resources.Software or ResourceVersion RequiredNetBeans IDEversion 6.7Java Development Kit (JDK)version 6 orversion 5Setting Up the ProjectTo create an IDE project:1.Start NetBeans IDE.2.In the IDE, choose File > New Project (Ctrl-Shift-N), as shown in the figure below.3.In the New Project wizard, expand the Java category and select Java Application as shown in the figure below. Thenclick Next.09/10/12 19:44testwww: NetBeans IDE 6.7 Java Quick Start TutorialPágina 2 de 6http://testwww.netbeans.org/kb/docs/java/quickstart.html4.In the Name and Location page of the wizard, do the following (as shown in the figure below):In the Project Name field, typeHelloWorldApp.Leave the Use Dedicated Folder for Storing Libraries checkbox unselected.In the Create Main Class field, typehelloworldapp.HelloWorldApp.Leave the Set as Main Project checkbox selected.09/10/12 19:44testwww: NetBeans IDE 6.7 Java Quick Start TutorialPágina 3 de 6http://testwww.netbeans.org/kb/docs/java/quickstart.html5.Click Finish.The project is created and opened in the IDE. You should see the following components:The Projects window, which contains a tree view of the components of the project,including source files, librariesthat your code depends on, and so on.The Source Editor window with a file calledHelloWorldAppopen.The Navigator window, which you can use to quickly navigate betweenelements within the selected class.The Tasks window, which lists compilation errors as well other tasksthat are marked with keywords such as XXXand TODO.09/10/12 19:44testwww: NetBeans IDE 6.7 Java Quick Start TutorialPágina 4 de 6http://testwww.netbeans.org/kb/docs/java/quickstart.htmlAdding Code to the Generated Source FileBecause you have left the Create Main Class checkbox selected in theNew Project wizard, the IDE has created a skeletonclass for you.You can add the "Hello World!" message to theskeleton code by replacing the line:// TODO code application logic here

Compiling and Running the ProgramBecause of the IDE's Compile on Save feature, you do not have to manually compileyour project in order to run it in theIDE. When you save a Java source file, the IDEautomatically compiles it.To run the program:Choose Run > Run Main Project (F6).The next figure shows what you should now see.Congratulations! Your program works!If there are compilation errors, they are marked with red glyphsin the left and right margins of the Source Editor. Theglyphs in the leftmargin indicate errors for the corresponding lines. The glyphs in the rightmargin show all of the areas ofthe file that have errors, including errorsin lines that are not visible. You can mouse over an error mark to get adescription of the error. You can click a glyph in the right margin to jumpto the line with the error.Building and Deploying the ApplicationOnce you have written and test run your application, you canuse the Clean and Build command to build your applicationfor deployment.When you use the Clean and Build command, theIDE runs a build script that performs the followingtasks:Deletes any previously compiled files andother build outputs.Recompiles the application and builds a JAR filecontaining the compiled files.To build your application:Choose Run > Clean and Build Main Project (Shift-F11).You can view the build outputs by opening the Files window and expandingthe HelloWorldApp node.The compiledbytecode fileHelloWorldApp.class

Next StepsYou now know how to accomplish some of the most common programming tasks in the IDE.To learn more about the IDE workflow for developing Java applications,including classpath management,seeDevelopingand Deploying General Java Applications.To find information specific to the kind of applications you are developing, use the NetBeans IDElearning trail for that typeof application. Each learning trail contains a series of tutorials andguides that range in scope from basic to advanced. Thefollowinglearning trails are available:General Java DevelopmentIntegration with External Tools and ServicesJava and JavaFX GUIsJava Web ApplicationsEJB and Web Service ApplicationsPHP ApplicationsDynamic LanguagesNetBeans Platform and Module DevelopmentC/C++ ApplicationsMobile Applications