Build Hello World

You can quickly create a project in which to organize your application files, and create a Java class. Then work in JDeveloper's IDE to edit, compile, and run your application. While getting started, you can customize the project properties and rearrange IDE windows to meet your needs, and use the Help Center to find relevant information.

Create a New Application and Project: Use the Create Application wizard to create a new application and project for your Java application.

Create a Java Class: Use the Create Java Class dialog to create a class file and specify the details.

Edit Source Files: Use the Java source editor, which provides functionality such as Java Code Insight and import statement assistance, to edit your source files.

Set Project Properties: Use the Project Properties dialog to change project settings for the application.

Profile: Use the profiler to find programming inefficiencies, performance problems, and memory leaks in your application code.

 

Create a New Application and Project

tell me more icon Creating a New Application and Project

The application control file is the highest level in the organizational structure. It stores information about the objects you are working with, while you are creating your application. It keeps track of your projects and the environment settings while you are developing your Java program.   [ tell me more...]





  1. Open the Create Application wizard [ File > New > General > Applications > Application.
  2. Enter the application name MyJavaApplication to follow along with the example.
  3. Select Generic Application from the Applica tion Template list, and click Next .
  4. In the Name your Project page, accept the default project name and click Finish .

    tell me more icon Application Navigator

    The Application Navigator is your view into the files that make up the different applications, organized into application control files and projects. Additionally, the Application Navigator allows you to customize the components and level of components that make up your application.   [ tell me more...]




    tell me more icon In the IDE

    When you create your application and project files, the Application Navigator should look like this:  [ tell me more...]



 

Create a Java Class

tell me more icon Creating a Java Class

New classes can be created and added to your project after you build the initial set of project files.  [ tell me more...]





  1. In the Application Navigator, select the project you just created and open the Create Java Class dialog [ File > New > General > Java Class] .
  2. Accept the default name and package for the class.
  3. In the Extends field, accept the default superclass.
  4. Under Optional Attributes, select Main Method to render the class runnable. Accept the remaining defaults and click OK.

    tell me more icon Structure Window

    The Structure window offers a structural view of the data in the document currently selected in the active window of those windows that participate in providing structure: the Application Navigators, the editors and viewers, and the Property Inspector. For a Java file, you can view code structure, UI structure, or UI model data.   [ tell me more...]



  5. In the Structure window, double-click the main method to highlight it in the source editor.

    tell me more icon In the IDE

    When you create your Java class, the Application Navigator should look like this, if all nodes are expanded:  [ tell me more...]



 

Edit a Java Class with the Source Editor

tell me more icon Editing a Java Class with the Source Editor

The Create Field dialog lets you create a new field of a given type, and set modifiers for the field. You can also generate event notifications when the property is changed.   [ tell me more...]





  1. In the Structure window, right-click Class1 and choose New Field .
  2. In the Create Field dialog enter greeting as the field name. Confirm that String is selected as the type and private is selected as the scope.
  3. Select Generate JavaBean Property Support , Readable and Writable . Then click OK.
  4. Repeat steps 1 through 3 to create a second new field, name.
  5. In the Structure window, right-click Class1 and choose Generate Constructor fro m Fields .
  6. Select both fields, then click OK.
  7. In the source editor, add code in the main() method. For example, create a BufferedReader object, and use System.out to get the name and greeting and then output it.
    code sample icon Use sample code

    tell me more icon Using Java Source Editor Features

    Features available to you in the Java source editor include:   [ tell me more...]



  8. To (optionally) change any of the source editor default settings, open the Preferences dialog, Code Editor: Java page [ Tools > Preferences > Code Editor > Java]  and customize the options.
  9. Click save all Save All to save your work.

    tell me more icon In the IDE

    If you added the code sample and import statements, the code in the source editor should look like this:  [ tell me more...]



 

Specify Project Properties

tell me more icon Specifying Project Properties

The Project Properties dialog allows you to set properties such as source paths, output paths, the class path, dependencies on other projects, and the default run target.   [ tell me more...]





  1. In the Application Navigator, select the project and open the Project Properties dialog, Run/Debug/Profile page [ Tools > Project Properties > Run/Debug/Profile] .
  2. To edit the default run configuration, select the Default profile and click Edit .

    tell me more icon Edit the Run Configuration

    JDeveloper allows you to control how your application is run, including the default run target, JVM, console I/O settings, and proxy information by selecting and editing the Default profile on the Run/Debug/Profile page of the Project Properties dialog.  [ tell me more...]



  3. On the Launch Settings page of the Edit Run Configuration dialog, browse for the project and select Class1.java to specify it as the default run target.
  4. To pass an argument to a class, enter an argument such as Hello in the Program Arguments field.
  5. On the left select the Tool Settings node.
  6. To enable input for a class, select Allow Program Input and click OK.
  7. Click OK to close the Project Properties dialog.

    tell me more icon In the IDE

    Project properties are not viewable in the IDE after you close the dialog, but you can easily display them again by selecting the project node and clicking the project properties icon Project Properties icon in the Application Navigator toolbar.   [ tell me more...]



 

Run a Project

tell me more icon Running a Project

Since the default run configuration tool settings specify that the project will be compiled before running, you do not need to compile the project manually. Source files will always be saved and compiled prior to running, unless you change this setting.  [ tell me more...]





  1. In the Application Navigator, right-click the project and choose Run .

    tell me more icon Compiling

    Although your code is compiled before running, you can alternatively compile your code at any time. You can compile several nodes in an application at once, for example, the entire application, the entire project, or specific Java files. To start the compiler, right-click a node in the Application Navigator and choose Make or Rebuild.  [ tell me more...]



  2. In the Log window, Running page, enter " Hello" in the Input field and press Enter.
  3. Then enter " World" in the Input field and press Enter.

    tell me more icon In the IDE

    When you run a class file in JDeveloper, the Log window opens and displays details about the running process.  [ tell me more...]



 

Debug a Java Application

tell me more icon Debugging a Java Application

You can customize various debugger window settings, including the column resize mode, and set the debugger start option by choosing Tools then choose Preferences then choose Debugger .   [ tell me more...]





  1. In the source editor, set a breakpoint on an executable statement by clicking in the margin to the left of the BufferedReader reader = new BufferedReader line to display a breakpoint icon breakpoint icon.
  2. In the Application Navigator, right-click the project and choose Debug to start the debugger.

    tell me more icon Debugger Icons

    These icons are available from the toolbar, to assist you in debugging:   [ tell me more...]



  3. When the class stops at the first breakpoint, click step into icon Step Into to trace into a method call or click step over icon Step Over to step over it.
  4. End the debugging session at any time by clicking terminate icon Terminate.

    tell me more icon In the IDE

    When you start the debugger, the Log window opens and displays the debugging trace.   [ tell me more...]



 

Profile Application Code

tell me more icon Profiling Application Code

The profiler helps you find programming inefficiencies, performance problems, and memory leaks in your application code. You can specify classes and packages to include and exclude by choosing Tools then choose Preferences then choose Profiler . JDeveloper provides both CPU and memory profiling.  [ tell me more...]





  1. In the Application Navigator, select the project and open the Project Properties dialog, Run/Debug/Profile page [ Tools > Project Properties > Run/Debug/Profile]  again.
  2. Select the Default profile and click Edit , then select the Tool Settings | Profiler node.
  3. Select Begin Use Case on Application Startup . Then click OK.
  4. Click OK to close the Project Properties dialog.
  5. From the main menu choose Run then choose CP U Profile Project1.jpr to start running the CPU profiler.
  6. Use the icons on the profiler window toolbar to control the profiling session.

    tell me more icon Profiler Window Toolbar

    These items are available from the toolbar in the profiler window:  [ tell me more...]



  7. From the main menu choose Run then choose Memor y Profile Project1.jpr to start running the memory profiler.
  8. When prompted, click Show Updates.
  9. End the profiling session at any time by clicking terminate icon Terminate.

    tell me more icon In the IDE

    The CPU Profiler displays data in two windows: Hotspots and Call Stacks.  [ tell me more...]



 



Copyright © 1997, 2009, Oracle. All rights reserved.

false ,,,,,,,,,,,,,,,