Oracle_jdeveloper_11g_教程_第1頁(yè)
Oracle_jdeveloper_11g_教程_第2頁(yè)
Oracle_jdeveloper_11g_教程_第3頁(yè)
Oracle_jdeveloper_11g_教程_第4頁(yè)
Oracle_jdeveloper_11g_教程_第5頁(yè)
已閱讀5頁(yè),還剩74頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Introduction to the JDeveloper IDE PurposeThis tutorial provides a tour of the major components in the Oracle JDeveloper 11g .0 IDE, and shows you how they can be used to build a basic Java based application. Time to CompleteApproximately 50 minutes. TopicsThis tutorial covers the following

2、topics:OverviewPrerequisitesLaunching JDeveloper 11gCreating Your First ApplicationCreating Your First Java ClassUsing the Source Editor with Your Java ClassDebugging Java ProgramsManaging FilesCreating JSF Pages and Managed BeansSummaryViewing ScreenshotsPlace the cursor over this icon to load and

3、view all the screenshots for this tutorial. (Caution: This action loads all screenshots simultaneously, so response time may be slow depending on your Internet connection.) Note: Alternatively, you can place the cursor over an individual icon in the following steps to load and view only the screensh

4、ot associated with that step. You can hide an individual screenshot by clicking it. OverviewIn the tutorial, you learn how to create a simple Java class. Using your new class, you then explore some of the features of the JDeveloper IDE, including Code Assist and the Debugger.Back to Topic ListPrereq

5、uisites Before you begin this tutorial, you should:Have access to or have installed Oracle JDeveloper 11g .0. You can download it from Oracle Technology Network. Back to Topic ListLaunching JDeveloper 11g1.Start JDeveloper by selecting If a dialog box opens asking if you would like to migrat

6、e from a previous version of JDeveloper, click NO. 2.In the Select Role dialog, choose Default Role and click OK.Note: Shaping, which is based on the role of the user, allows the JDeveloper environment to tailor itself. It does this by removing unneeded items from the menus, preferences, new gallery

7、, and even individual fields on dialogs. Shaping can even control the default values for fields on dialogs within the tool. When you first start JDeveloper, you are prompted to choose a role that describes how you use JDeveloper. If you choose a role of "Java Developer" versus "CRM Ap

8、plications Developer" versus "Default Role" you will get a totally different experience!Close the Tip of the Day window. 3.Once loaded, the JDeveloper IDE appears. The very first time you open JDeveloper, the Start Page displays. You can re-invoke the Start Page later by choosing

9、 Help | Start Page.Notice the various options available to help you learn about JDeveloper. After exploring these options, close the Start Page by clicking the X on its tab (the X appears when you mouse over the tab). Back to Topic List Creating Your First ApplicationThe application is the highest l

10、evel in the control structure. It is a view of all the objects you need while you are working. An application keeps track of all your projects while you are developing your Java programs.Applications are stored in files with the extension .jws. When you open JDeveloper, the last application used is

11、opened by default, so that you can resume where you left off.When creating a new application you have the option to base it on a template. The application template you select determines the initial project structure, that is, the named project folders within the application.In JDeveloper you always

12、work with projects contained within an application. A JDeveloper project is a logical grouping of related files. You can add multiple projects to an application to easily access, modify and reuse your source code.The Application Navigator is the main JDeveloper window from which you access the compo

13、nents of your application. The structure of the Application Navigator is hierarchical and supports, for a given application, projects, images, .html files, and many more. By default the Application Navigator displays on the left side of the IDE.To create an application, perform the following steps:

14、1.Click the New Application link in the Application Navigator.  2.In the Create Application dialog, modify the default application name to MyFirstApp, and make sure that the Application Package Prefix is empty. Note that the Directory Name changes accordingly.  3.Scroll down the Applicatio

15、n Template pane to review the list of available templates. Select the Generic Application to configure this application with a single project that has access to all JDeveloper technologies.Click Next. 4. In this new step, change the default Project Name to MyProject, and then click Finish. 

16、;5. In the Application Navigator, projects are displayed as the second level in the hierarchy under the application. The Application Navigator should look like this:Note that the project folder is a child of the application folder. 6. The Visual Editor displays an application Overview informati

17、on about the various categories of JDeveloper, and at the bottom of each category, provides links to enable you to discover more information about that category. 7.Within the Application Navigator, notice the three titles corresponding to accordion type of panes.  8.Click in the accordion

18、title to expand it. 9.Click in the title bar of an expanded accordion to collapse it. 10.Accordions are also available in other panes of JDeveloper such as the Structure pane or Resources Palette.Back to Topic ListCreating Your First Java ClassTo create a new Java class, perform the follow

19、ing steps:1.Right-click the MyProject node in the Application Navigator and select New. from the context menu. 2.The New Gallery displays. By default, the first category, General, is highlighted in the Categories list. The other categories enable you to work with different technologies to build

20、 the various tiers of an application. Click the + sign to the left of the General category to expand it, and take note of the sub-categories that are available. Select the Java node, and then select Java Class in the Items list in the right portion of the window. Click OK.3.In the Create Java Class

21、dialog, change the default name to Dog. Because you did not specify a package name when creating the application, the package name defaults to the project name in lowercase. You could change this if desired, but you do not need to do so for this tutorial.Accept all other defaults and click OK. 

22、4.The new class opens automatically in the source editor, where you see the skeleton class definition.Add a method to the class. After the constructor, press Enter to create a new line, and type the following code: public String sayHi() Notice that the line that you just entered has a wavy red line

23、under it, indicating a problem with the syntax. There are also red boxes in the right margin of the source editor. If you mouse over these boxes or over the wavy red line, a tooltip displays information about the error or errors. You see other examples like this in Working with Code Assist later in

24、this tutorial.   5.At the end of the line, press Ctrl+Shift Enter and JDeveloper provides auto-completion of the method structure, and some of the error indicators disappear. However some indicators remain, showing that the syntax is still not complete.Notice that auto-completion is also access

25、ible from the Source | Complete Statement menu option.6.Add code to provide the missing return statement.In the blank line between the two curly braces that were added to the method, add the following code:return " woof " + "Kate"Notice that when you type the first double quote s

26、ymbol ("), JDeveloper automatically provides you with the second double quote, enclosing the cursor between them, so that you can easily type the literal. Notice also that a green box has appeared in the upper right margin to indicate that there are now no syntax errors.Back to Topic List Using

27、 the Source Editor with Your Java Class Editors are where most of the application development work takes place; this is where you write code and design user interfaces. In this topic you explore some of the features of the Java Source Editor. Using code templates Compiling and running your Java clas

28、s Working with Code AssistSearching and Highlighting CodeRefactoring code Viewing code modification historyNavigating through code Using code templatesCode templates assist you in writing code more quickly and efficiently while you are in the source editor. You can edit existing templates or create

29、your own. This topic shows you how to use some of the existing code templates in the Dog class.1.There is a code template for adding a main method to a Java class.Press Enter to create a new line after the sayHi() method. Type the letter m, and press Ctrl+Enter to invoke code templates.The main meth

30、od template is suggested.  2.Press Enter again to accept the suggestion and incorporate the template.3.Create a Dog object in the main method by adding the following code:Dog myDog = new Dog();If you mouse over the myDog variable, a tooltip displays to tell you that the variable has not been us

31、ed. You see other examples like this in Working with Code Assist later in this tutorial. 4. Add a new line and press Ctrl+Enter to see the list of code templates that are available. 5. You decide to create an integer-based loop using a for type code template. Type fo to restrict the list.F

32、our templates are suggested. 6. Double-click the third of the four suggestions, the fori intBased "for" Loop (Simple Limit), to select it.The template code is incorporated into the file. 7. Modify the template code.Replace i with count. Notice that changing the first i variable n

33、ame in the loop changes all subsequent references.Limit the loop to 3 iterations. 8. Enter a statement. Place the cursor on the blank line inside the curly braces of the for loop, and type System. (be sure to include the dot at the end of the word.) A list of suggested code appears.Type the let

34、ter o and press Enter to select the suggested out code. Type . (dot), and when the list of suggested code appears, type the letter p, then scroll down and double-click the println() suggested code. Note: An even quicker way to enter a System.out.println() statement is to enter sop and then press Ctr

35、l+Enter. The technique above is given to illustrate how to use code completion. 9. Add code to use the loop to display the sayHi message. Inside the parentheses after println, you want to enter the following code: count + myDog.sayHi(). Start typing count + myDog. and select the sayHi method fr

36、om the list.The complete line should read: System.out.println(count + myDog.sayHi(); 10.Right-click within the editor view and select Reformat to have JDeveloper restructure your code. 11.Your code should now look like this: 12.Save your work. Go to File->Save All, or click the Sav

37、e All button in the toolbar.Back to TopicCompiling and running your Java class When you successfully compile a .java file, you create a .class file in the src directory of the project. Compiling a class in JDeveloper automatically saves the .java file as well. When you run a class, it is automatical

38、ly compiled and saved. 1.In the Application Navigator or in the source editor, right-click and select Make from the context menu.  2.At the bottom right of the JDeveloper IDE, the log window should show successful compilation. If the log window does not display, use View | Log to display it ( o

39、r press Ctrl+Shift+L).Notice that when using the Make option to compile your class, JDeveloper saves all the files in your project. 3.In the Application Navigator or in the source editor, right-click again, and this time select Run from the context menu.4.The log window displays 3 counts of the

40、 ' woof Kate' message.Back to TopicWorking with Code AssistCode Assist examines your code in the editor and provides assistance to fix common problems. Here you use the Dog class to explore some examples of the suggestions that are offered.1.Create a Cat object.At the start of the main metho

41、d, just after the first curly brace, press Enter to create a new line. In the new line, enter the following code:Cat myCat = new Cat(); 2.Notice that the red wavy lines and margin indicators have again appeared. Place the mouse over a margin indicator to see what the problem is from the code po

42、pup window.Notice that the popup box displays the problematic lines as well as telling you what the problem is.3.Hover your mouse over the light bulb icon in the left hand margin of the 'cat' line. A message tells you that 'quick fixes and code assists' are available for this line. &

43、#160;4.Click the icon to see what they are.You need a Cat class to instantiate a Cat object. If you click on the first suggestion in the list offered, JDeveloper creates a class called Cat. On this occasion you don't want to create the Cat class immediately, so you remind yourself to do it later

44、 by setting yourself a task: press Enter after new Cat(); to open a new line and in the new line enter the following code:/TODO create a Cat class5.Select View | Tasks to see a list of tasks that you have created.6.The Tasks window displays a list of the tasks you have created (in this case, it is y

45、our only task).7.If you double-click a task in the list (create a Cat class in our example), JDeveloper takes you to the relevant task, inserting the cursor at the start of the line.8.Notice the pink marker at the top right margin of the editor. It indicates where you have created a task. Hover over

46、 the marker with the mouse to see what the task is.9.Comment out the line that creates the Cat object. Notice that the red markers have now disappeared, to be replaced by a green marker indicating that there are no errors in your code.10.Check out the new toolbar in the code editor. Add two variable

47、s to the class. Hit Enter to create a new line after the class declaration. Declare two variables as follows:String name;int age; 11.In the code editor, right click and select the Generate Accessors option from context. The generate accessor option is also available from the code editor toolbar

48、 using the Generate Accessors icon.  12.In the Generate Accessors dialog, check the Dog box to generate Getter and Setter methods for both variables. Notice that you can define the scope for the methods, and define other properties to be implemented in the setter methods such as involving liste

49、ners and verifying the new value.Click OK. Getter and Setter methods are generated into the Dog class. 13.Right click within the code editor and from context select Source -> Generate Constructor from fields. 14.In the Generate Constructor from Fields dialog, select both fields and clic

50、k OK.  15.The new constructor method is added to your code. 16.Click the Undo button since we don't need this constructor method.Back to TopicSearching and Highlighting codeUsing the code editor, you can search for text and display all occurrences of the search criteria. You can also u

51、se a highlighting facility that retrieves all occurrences of an object. 1.Use the Search/Code highlight feature. In the Search box on the left of the code editor toolbar, type name. The first instance of name found after your cursor location is highlighted in the code editor.  2.Click the '

52、down' arrow to move to the next occurrence of the string.  3.Click the binocular icon to have access to additional options and check the Highlight Occurrences option. Then, click the down arrow to highlight all Occurrences.Notice that the search function retrieves all Occurrences of a strin

53、g in the code. 4.Click the Clear All Highlighting icon in the editor toolbar. 5.Remove name from the Search field. 6.From the menu, choose Search | Auto Code Highlight.  7.In the code editor click within the age parameter of the setAge method. Notice that then the highlighted occ

54、urrences are restricted to occurrences of the same semantic object. The age variable being excluded. 8.Now select the age variable in the setAge method to highlight all occurrences of that variable. 9.In the right margin, hover over the top yellow marker with the mouse to display the code.

55、  10.Double click this yellow marker. This moves you to the corresponding location in the source editor. 11.Configure JDeveloper to allow a 'ghost' window to display additional information. From the main menu, select Tools | Preferences. 12.In the Preferences dialog, expand th

56、e Code Editor node and select Code Insight. You can determine the way you want code insight to behave (when and how fast). There are many preferences you can set to customize your development environment.Click OK. 13.You can view the definition of a variable or method without navigating to a di

57、fferent file or opening a new editor.You can hold down the Shift key and then hover over a variable or method to show its definition in a ghost window. This feature makes it convenient to quickly view code without moving cursor focus from your current code.In the structure pane, move your mouse over

58、 one of the nodes and click the Shift key. This way you can also display the code front structure from the class structure.The ghost window closes as you release the shortcut keys. 14.Now back in the source editor window, hover your mouse over the sayHi method in the System.out.println(count + myDog.sayHi(); and press the Ctrl+1 keys. This displays the method definition. 15.Reformat your code by clicking the Reformat icon in the code editor to

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論