Oracle WebLogic Server 12.1.3 Developer Guide: Running WebLogic Server 12.1.3 on JDK 1.8

 

Before You Begin

Purpose

Use Java Development Kit (JDK) 1.8 with WebLogic Server 12.1.3, including installing, creating a domain, and running an application that uses the JDK 1.8 feature for lambda expressions.

Time to Complete

30 minutes

Background

Lambda expressions enable you to  pass functionality as an argument to another method, such as what action should be taken when someone clicks a button - treat functionality as method argument, or code as data. Lambda expressions let you express instances of single-method classes compactly. In this tutorial, a calculator application with mathematical operations utilizes lambda expressions.

Hardware and Software Requirements

The following is a list of hardware and software requirements:

  • A Linux development machine with sufficient CPU, memory, and hard disk space
  • Sufficient hardware to run WebLogic Server (For details, see the list of certified platforms.)

Prerequisites

Before starting this tutorial, you should have access to Oracle Technology Network to download the WebLogic Server 12.1.3 Zip Distribution and the NetBeans IDE.

 

Downloading and Installing JDK 1.8

  1. Access the Linux development machine and start a web browser with internet access.

  2. Navigate to http://www.oracle.com/technetwork/java/javase/downloads/.

  3. Click the JDK 1.8 download link and click Accept License Agreement.

  4. Download the JDK 1.8 .tar.gz file to your Linux machine in the /u01 directory.

    Note: this tutorial uses jdk-8u31-linux-x64.gz - other versions of JDK 1.8 may also work but they have not been tested with this tutorial.

  5. Open a secure shell session into the Linux machine.

  6. Execute cd /u01 to change directory.

  7. Execute tar -xzvf jdk-8u31-linux-x64.gz (or the JDK 1.8 version you downloaded) to extract the JDK.

  8. Note that the JDK_HOME is /u01/jdk1.8.0_31.

 

Downloading the WebLogic Server 12.1.3 Zip Distribution

  1. Open a browser and navigate to http://www.oracle.com/technetwork/middleware/weblogic/downloads/wls-for-dev-1703574.html.

  2. On the Downloads tab, click Accept License Agreement, and then click Zip distribution Update 1 for Mac OSX, Windows, and Linux.

  3. The site may prompt you for your Oracle Technology Network (OTN) user name and password.

  4. Log in to Oracle Technology Network and save the zip file to your local file system. This tutorial uses the location /u01.

  5. Note that this tutorial uses the WebLogic Server Zip Distribution Update 1 - other versions of the WebLogic Server Zip Distribution may also work but they have not been tested with this tutorial.

 

Installing and Configuring the WebLogic Server 12.1.3 Zip Distribution with JDK 1.8

  1. Open a Linux terminal shell and log in as the oracle user.

  2. Execute export JAVA_HOME=/u01/jdk1.8.0_31 to set the JAVA_HOME environment variable.

  3. Execute export MW_HOME=/u01/wls12130 to set the MW_HOME environment variable.

  4. Execute cd /u01 to change the directory to the location where you want to install WebLogic Server. In this tutorial, /u01 is the location.

  5. Execute unzip wls1213_devzip_update1.zip to install the Zip Distribution in the /u01/wls12130 directory.

  6. Execute ./configure.sh to unpack the Java Archive (JAR) files.

  7. At the prompt, enter y to configure a new domain.

  8. At the prompts, enter a username (for example, weblogic) and a password, and then reenter the password.

    A domain called mydomain is created and the WebLogic Server starts.

    You successfully installed WebLogic Server 12.1.3, and the new domain is running.

    In the next tutorial section, you will be working with the WebLogic Server code examples domain. Next, shut this WebLogic Server down.

 

Downloading the WebLogic Server Application for JDK 1.8

  1. Download this WebLogic Web application, calculator.war to the Linux machine.

  2. Copy the calculator.war file to the /u01 location.

    You will deploy the calculator.war web application in the next steps.

 

Deploying the JDK 1.8 Application to  WebLogic Server 12.1.3

The calculator application uses the JDK 1.8 feature for lambda expressions - in the code below, the servlet doPost method declares several math functions: multiplication, division, addition, and subtraction. Those functions are used to calculate the result.

  1. Open a browser on the Linux machine and navigate to http://localhost:7001/console to access the WebLogic Administration Console.

  2. Enter weblogic for Username and welcome1 for Password and click Login.

  3. In the Domain Structure pane, click Deployments.
  4. In the Summary of Deployments pane, click the Install button.
  5. In the Install Application Assistant, navigate to the /u01 directory, select the calculator.war file and click Next.
  6. Click Next to Install this deployment as an application.

  7. Click Next to accept the application name.

  8. Click Finish to complete the deployment.

    The calculator.war application is deployed.

  9. In the browser, navigate to the http://localhost:7001/ URL and the calculator application displays.

  10. Enter a pair of numbers, select an operation, and click the Calculate button. The result displays.

  11. The next section in this tutorial uses the source code for the calculator application and NetBeans to build and deploy the calculator application to this WebLogic Server. Therefore, delete the calculator application from this WebLogic Server.

  12. Navigate to http://localhost:7001/console to access the WebLogic Administration Console.

  13. In the Domain Structure pane, click Deployments.

  14. Click the check box next to the calculator application and click the Delete button.

    The calculator application is deleted from this WebLogic Server and you are ready to proceed to the next section.

 

Downloading and Installing NetBeans 8.0.2 using JDK 1.8

  1. In the browser navigate to https://netbeans.org/downloads/.

  2. Select Linux (x86/x64) for Platform and click the link to download the NetBeans installer.

  3. Save the NetBeans installer archive file to your local file system.

  4. On the Linux machine, open a secure shell as the oracle user.

  5. In the secure shell terminal session, move the NetBeans installer archive file to the /u01 directory.

  6. Change to the /u01 directory and execute ./netbeans-8.0.2-linux.sh to start the installer.

  7. Click Next.

  8. Click I accept the terms in the license agreement and click Next.

  9. Click I accept the terms in the license agreement and click Next.

  10. Enter /u01/netbeans-8.0.2 for the NetBeans IDE location, enter /u01/jdk1.8.0_31 for the JDK location, and click Next.

  11. Enter /u01/glassfish-4.1 for the GlassFish location, enter /u01/jdk1.8.0_31 for the JDK location, and click Next.

  12. Click Install.

  13. Click Finish.

 

Configuring NetBeans 8.0.2 for WebLogic Server 12.1.3

  1. In the secure shell on the Linux machine, execute cd /u01/netbeans-8.0.2/ to change to the NetBeans IDE directory.

  2. Execute bin/netbeans to start the NetBeans IDE.

    The NetBeans IDE displays.

  3. Click the Services tab in the NetBeans IDE, then right-click the Servers entry and select Add Server... to start the process of configuring WebLogic Server.

  4. In the Add Server Instance window select Oracle WebLogic Server and click Next.

  5. Enter /u01/wls12130/wlserver for the Server Location and click Next.

  6. Enter /u01/wls12130/user_projects/domains/mydomain for the Domain, weblogic for Username, welcome1 for Password and click Finish.

    The new Oracle WebLogic Server displays in the Servers entry.

 

Downloading the NetBeans Project for JDK 1.8

  1. Download this NetBeans Web application project, java8weblogic.tar to the Linux machine.

  2. Copy the java8weblogic.tar file to the /u01 location.

  3. In the secure shell session on the Linux machine, execute tar -xvf java8weblogic.tar to extract the project.

 

Opening and Running the JDK 1.8 Web Application in NetBeans 8.0.2

  1. In the NetBeans IDE, select the File menu and click Open Project...

  2. Select the java8weblogic project and click Open Project.

  3. Expand the java8weblogic project in the left pane and open the index.jsp file.

    The index.jsp file displays - notice that the page is a form that performs a POST to the calculator servlet.

  4. Right-click the java8weblogic project and select Run. The JDK 1.8 calculator application displays.

 

Want to Learn More?

 

Credits