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
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...]
Open
the Create Application wizard [File > New > General > Applications > Application] .
Enter the application name MyJavaApplication to
follow along with the example.
Select Generic Application from
the Application Template list,
and click Next.
In the Name your Generic Project page, accept the default project
name and click Finish.
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...]
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
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...]
In the Application Navigator, select the project you just created and open
the Create Java Class dialog [File > New > General > Java Class] .
Accept the default name and package for the class.
In the Extends field,
accept the default superclass.
Under Optional Attributes,
select Generate Main Method to
render the class runnable. Ensure that Public and Generate
Default Constructor are also selected and
click OK.
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...]
In the Structure window, double-click the main method to
highlight it in the source editor.
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
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...]
In the Structure window, right click Class1 and select
New Field.
In the Create Field dialog enter greeting as the field
name. Confirm that String is
selected as the type and the scope is public.
Select static, Generate
JavaBean Property Support, Readable and Writable. Then click OK.
Repeat steps 1 through 3 to create a second new field,
name.
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. Use sample code
To add an import statement for each referenced class you added, place the cursor on the ragged red line and press Alt+Enter.
Using Java Source Editor Features
Features available to you in the Java source editor include: [tell me more...]
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.
Click Save
All to save your work.
In
the IDE
If you added the code sample and import statements, the code in the Java source editor should look
like this: [tell me more...]
Specify Project Properties
Specifying
Project Properties
The Project Properties dialog allows you to set properties such as source paths,
output paths, the classpath, dependencies on other projects, and the default run target. [tell me more...]
In the Application Navigator, select the project and open
the Project Properties dialog, Run/Debug/Profile page [Tools > Project Properties > Run/Debug/Profile] .
To edit the default run configuration, select the Default profile and click Edit.
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...]
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.
To pass an argument to a class, enter an argument such as Hello in the Program Arguments field.
On the left select the Tool Settings node.
To enable input for a class, select Allow Program Input and click OK.
Click OK to close the Project Properties dialog.
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 in the Application Navigator toolbar. [tell me more...]
Run a Project
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...]
In the Application Navigator, right-click the project and choose Run Project.
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...]
In the Log window, Running page, enter "Hello" in
the Input field
and press Enter.
Then enter "World" in the Input field
and press Enter.
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
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 Preferences Debugger. [tell me more...]
In the Java source editor, set a breakpoint on an
executable statement by clicking in the margin to the
left of the first BufferedReader reader1 = new BufferedReader line to
display a breakpoint
icon.
In the Application Navigator, right-click the project and choose Debug to start the debugger.
Debugger Icons
These icons are available from the
toolbar, to assist you in debugging: [tell me more...]
When the class stops at the first breakpoint, click Step
Into to trace into a method call or click Step
Over to step over it.
End the debugging session at any time by clicking Terminate.
In the IDE
When you start the debugger, the Log window opens and
displays the debugging trace. [tell me more...]
Profile Application Code
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 Preferences Profiler.
JDeveloper provides both CPU and memory profiling. [tell me more...]
In the Application Navigator, select the project
and open
the Project Properties dialog, Run/Debug/Profile page [Tools > Project Properties > Run/Debug/Profile] again.
Select the Default profile
and click Edit, then
select the Tool Settings | Profiler node.
Select Begin Use Case
on Application Startup. Then click OK.
Click OK to close the Project
Properties dialog.
From the main menu
choose Run CPU
Profile <project_name> to start running
the CPU profiler.
Use the icons on the profiler window toolbar to control the profiling session.
Profiler
Window Toolbar
These items are available from the toolbar in the profiler
window: [tell me more...]
From the main menu
choose Run Memory
Profile <project_name> to start running
the memory profiler.
End the profiling session at any time by clicking Terminate.
In the IDE
The CPU Profiler displays data in two windows: Hotspots and Call Stacks. [tell me more...]