Oracle ADF 新手教程(一) JDeveloper IDE

本文档是Oracle ADF新手教程的第一部分,主要介绍了如何启动和使用JDeveloper IDE。从创建新应用开始,逐步演示了创建Java类、设置代码模板、调试、代码格式化以及使用JDeveloper的其他特性,如JavaServer Faces (JSF) 项目、代码补全和调试器等。
摘要由CSDN通过智能技术生成
This tutorial provides a tour of the major components in the Oracle JDeveloper 1111.1.2.0.0 IDE, and shows you how they can be used to build a basic Java-based application.
show more or lessRead more...
Purpose Duration Application
This tutorial shows you how to work with the JDeveloper IDE. To see the complete application you will create, click the Download button to download a zip of the finished application, and unzip it to your JDeveloper mywork folder. 105 minutes Download My First Application Solution.zip

Step 1: Launch JDeveloper
  1. Start JDeveloper by selecting Start > Programs > Oracle Fusion Middleware 11.1.2.0.0 > JDeveloper Studio 11.1.2.0.0

    Programs menu

    If a dialog box opens asking if you would like to import preferences from a previous JDeveloper installation, click NO.

  2. In the Select Role dialog, choose Studio Developer and click OK.

    Role selection
    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, and even individual fields on dialogs. Show more or lessRead more...

    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 choosingHelp > Start Page.

    Notice the various options available to help you learn about JDeveloper. After exploring some of these options, close the Start Page by clicking the X on its tab (the X appears when you mouse over the tab).

    Start page
Step 2: Create Your First Application
  1. Click the New Application link in the Application Navigator.

    Application Navigator with cursor on New Application menu option
  2. In the New Gallery, choose the Custom Application and click OK.

    New Gallery with Custom Application selected
  3. In the Name your application page of the Create Custom Application wizard, modify the default application name to MyFirstApplication, and make sure that the Application Package Prefix is empty. Note that the Directory Name changes accordingly. Click Next.

    Create Custom App wizard first page -with MyFirstApplication in the Name field
  4. In the Name your project page of the wizard, change the default project name to MyProject, and in the list of available project features, select JavaServer Faces (JSF) and click the Add button to move it into the selected pane.

    Page 2 of the wizard with MyProject in the Name field and JavaServerFaces selected in the Avaliable technologies pane

    Notice that Java, JSP and Servlets, and XML are also moved into the Selected pane.

    Java, JavaServerFaces and JSPandServlets display in the Selected pane

    Click Next.

  5. In the Configure Java settings page of the wizard, accept all defaults and click Finish.Page 3 of wizard with 'myproject' displayed in package name field

    The application is the highest level 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.Show more or lessRead more...
  6. In the Application Navigator, projects are displayed as the second level in the hierarchy under the application. The Application Navigator should look like this:

    App Navigator with MyProject displayed.
    The Application Navigator is the main JDeveloper window from which you access the components of your application. Show more or lessRead more...

    Notice that the project folder is a child of the application folder.

  7. In the Application Navigator, notice the names of three accordion panes

    App Navigator with MyProject displayed plus the three accordions at base of window.
  8. Click an accordion name to expand it.

    App Navigator with one accordion node (Application Resources) expanded.
  9. Click the name of an expanded accordion to collapse it.

    As previous image but with the accordion node closed.
  10. Accordions are also available in other JDeveloper panes, such as the Structure window or Resource Palette.

Step 3: Create Your First Java Class
  1. Right-click the MyProject node in the Application Navigator and select New... from the context menu.

    App Navigator with the context menu for the project displayed and the New menu option selected
  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 other JDeveloper technologies to build the various tiers of an application.
    In the Items list in the right-hand pane select Java Class. Then click OK.

    New Gallery with Java Class selected.
  3. In the Create Java Class dialog, change the default class name to Dog
    Accept all other defaults and click OK.

    Create Java Class dialog with
  4. The new class opens automatically in the source editor, displaying 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()

    Source editor displayed with skeleton class definition. Students add

    Notice that the line that you just entered has a wavy red line 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 the Working with Code Assist topic later in this tutorial.

    Source editor with cursor over the red mark line in right-hand gutter. Tool tip displays message that the method is missing a return statement.
  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.

    Source editor completes method declaration by adding final curly bracket. But one red marker still remains.

    Notice that auto-completion is also accessible from the Source > Complete Statement menu option.

    Cursor is on the Complete Statement menu option under the Source menu option on top menu bar.
  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";

    Source editor with Gog Class code. Shows new return statement added:

    Notice that when you type the first double quote symbol ("), 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.

Step 4: Use Code Templates

Code templates are a feature of the Java Source Editor. Code templates assist you in writing code more quickly and efficiently while you are in the source editor. You can edit existing templates or create your own. This step 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.

    Source editor: shows template offering when letter 'm' is typed.

    The main method template is suggested.

  2. Press [Enter] again to accept the suggestion and incorporate the template.

    Source editor: main method code template is added to source.
  3. Create a Dog object in the main method by adding the following code:

    Dog myDog = new Dog();


    Source code editor: code to create Dog object added to main method.

    If you mouse over the 

  • 3
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值