dcsimg
December 15, 2018
Hot Topics:

Creating a Java Application in Oracle JDeveloper, Part 1

  • April 13, 2018
  • By Deepak Vohra
  • Send Email »
  • More Articles »

Oracle JDeveloper is an integrated development environment (IDE) for Java, Java EE, and the Application Development Framework (ADF). JDeveloper supports Java standards-based Web Services, including JAX-WS and JAX-RPC. JDeveloper is also a client for most commonly used relational databases, which include Oracle Database, MySQL database, IBM DB2 database, and SQL Server. In two articles, we shall discuss creating a Java application in JDeveloper. This article has the following sections:

Setting the Environment

Download and install Oracle JDeveloper 12.2.1.

Creating a Java Project

To create and run a Java application, we first need to create a Java project in JDeveloper. A Java project constitutes of a directory structure to create and run Java applications. The JDK and classpath used are pre-configured; so are the project properties and preferences, which may be customized. To create a new Java project, select File>New>Application, as shown in Figure 1. Alternatively, File>New>From Gallery may also be selected.

Using JDeveloper with Amazon Aurora, Part 2
Figure 1: File>New>Application

In the New Gallery wizard, select General>Applications in Categories, as shown in Figure 2. Select Java Desktop Application in Items and click OK.

Selecting Java Desktop Application in New Gallery
Figure 2: Selecting Java Desktop Application in New Gallery

The Create Java Desktop Application wizard gets started, as shown in Figure 3. The first window is Name your application. Specify an Application Name (HelloWorld) and the Directory gets configured. Click Next.

Create Java Desktop Application>Name your Application
Figure 3: Create Java Desktop Application>Name your Application

Next, the Select Build Environment window is displayed, as shown in Figure 4. The option Use JDeveloper's default build tools is selected by default. Click Next.

Select Build Environment
Figure 4: Select Build Environment

Next, the Name your project window is displayed, as shown in Figure 5. With the default Project Name (Client) and Directory, select Java in Project Features and click Next.

Name your project
Figure 5: Name your project

In the Configure Java settings window, specify a Default Package (helloworld) (see Figure 6). The Java Source Path and Output Directory get configured based on the application name specified earlier. Click Finish.

Configure Java settings
Figure 6: Configure Java settings

A new Java Desktop Application, HelloWorld, gets created and added to the Applications view, as shown in Figure 7. The Client project in the application also gets added.

New Java Desktop Application HelloWorld
Figure 7: New Java Desktop Application HelloWorld

Setting Project Properties

To find or modify the project properties, select Application>Project Properties, as shown in Figure 8.

Application>Project Properties
Figure 8: Application>Project Properties

Alternatively, right-click the Client project and select Project Properties, as shown in Figure 9.

Client>Project Properties
Figure 9: Client>Project Properties

The Project Properties window gets displayed, as shown in Figure 10. The Libraries and Classpath lists the libraries and jars in the classpath of the project. The Java SE Version is set to 1.8 by default and also labeled as Default. No modification or addition is required for a HelloWorld Java application.

Project Properties>Java SE Version
Figure 10: Project Properties>Java SE Version

The Compiler node displays the Java compiler settings (see Figure 11). The Current Compiler is listed as Javac. The JVM memory is set to 512m by default and may be modified by selecting the Out of Process checkbox, which makes the Out of Process JVM Options field editable.

Compiler Settings
Figure 11: Compiler Settings

The Compiler>Excludes is to specify any project files and directories to be excluded from the build. We don't need to exclude any files and directories. The Options section is to configure the various Javac options, as shown in Figure 12.

Javac options
Figure 12: Javac options

The Project Source Paths displays the settings for Java source paths, whether subfolders are to be included or excluded, the Output Directory for the class files generated, and the Default Package, as shown in Figure 13.

Project Source Paths
Figure 13: Project Source Paths

The project properties may be modified even after the Java application, including classes and interfaces, have been created. JDeveloper is not required to be restarted to apply the new project properties.

Next, we shall demonstrate creating a HelloWorld application consisting of a Java interface and a Java class that implements the interface.

Creating a Java Interface

To create a Java interface, right-click the Client project and select New>Java Interface, as shown in Figure 14.

Client>New>Java Interface
Figure 14: Client>New>Java Interface

Alternatively, select the Client project and click File>New>Java Interface, as shown in Figure 15.

File>New>Java Interface
Figure 15: File>New>Java Interface

As another alternative, select From Gallery with either of the preceding two options instead of selecting Java Interface. The New Gallery window gets displayed. Select General>Java in Categories and Interface in Items (see Figure 16).

Selecting Java Interface in New Gallery
Figure 16: Selecting Java Interface in New Gallery

The Create Java Interface window gets displayed, as shown in Figure 17. Specify an interface Name (HelloWorld) and the Package name is pre-configured to the Default Package setting in Configure Java Settings, as shown earlier in Figure 6. Click OK.

Create Java Interface
Figure 17: Create Java Interface

The Java interface HelloWorld gets created and added to the Client project, as shown in Figure 18. The Java source file for the interface gets generated in the Project Source Path directory.

Java Interface HelloWorld
Figure 18: Java Interface HelloWorld

Add a getMessage(String) method to the Java interface, as shown in Figure 19.

HelloWorld Interface with Method getMessage(String)
Figure 19: HelloWorld Interface with Method getMessage(String)

The HelloWorld interface is listed:

package helloworld;
public interface HelloWorld {
   String getMessage(String name);
}

Conclusion

In the first of two articles, we discussed creating a Java project in JDeveloper, setting project properties, and creating a Java interface for a Hello World Java application. In a subsequent article, we shall discuss creating and running a Java class.






Comment and Contribute

 


(Maximum characters: 1200). You have characters left.

 

 


Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap

Thanks for your registration, follow us on our social networks to keep up-to-date