Top Banner
315 A PPENDIX A Installation Instructions This appendix covers the installation of all the software required to develop web applications with WebSphere. We assume that you are starting with a clean development machine, and we do not assume any preinstalled requirements. We also cover the installation of middleware required to host the sample application devel- oped throughout this book. Although this is a step beyond the standard development of the appli- cation, we feel that it is important to be able to deploy the final product onto a separate hosting server. AUTHORS’ NOTE We know that one of the most frustrating aspects of purchasing a book with detailed code and installation examples is finding that the particular release of tools referenced in the book is no longer available, or discovering that user interface features of the installation proce- dure have changed so that you can no longer follow the instructions. An added feature of books in the developerWorks Series is that the book’s home page always has an updated version of the installation instructions for our examples. The home page for this book is www.ibm.com/developerworks/dwbooks/modernwebdev/index.html. Visit that page for the most up-to-date version of these instructions. Development Machine Installation To configure the development environment needed to follow the examples in this book, you must install several components. We cover installation of the following software: Java Runtime Environment, v1.7 Eclipse Juno IDE, v4.3 IBM WebSphere Developer Tools, v8.5.5 Source code for the book
19

Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Aug 04, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

315

A P P E N D I X A

Installation Instructions

This appendix covers the installation of all the software required to develop web applications with WebSphere. We assume that you are starting with a clean development machine, and we do not assume any preinstalled requirements.

We also cover the installation of middleware required to host the sample application devel-oped throughout this book. Although this is a step beyond the standard development of the appli-cation, we feel that it is important to be able to deploy the final product onto a separate hosting server.

AUTHORS’ NOTE

We know that one of the most frustrating aspects of purchasing a book with detailed code and installation examples is finding that the particular release of tools referenced in the book is no longer available, or discovering that user interface features of the installation proce-dure have changed so that you can no longer follow the instructions. An added feature of books in the developerWorks Series is that the book’s home page always has an updated version of the installation instructions for our examples. The home page for this book is www.ibm.com/developerworks/dwbooks/modernwebdev/index.html . Visit that page for the most up-to-date version of these instructions.

Development Machine Installation

To configure the development environment needed to follow the examples in this book, you must install several components. We cover installation of the following software:

• Java Runtime Environment, v1.7

• Eclipse Juno IDE, v4.3

• IBM WebSphere Developer Tools, v8.5.5

• Source code for the book

Page 2: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

316 Appendix A Installation Instructions

In addition, we cover installation of the following optional tools for mobile development:

• IBM Worklight Studio, v6.0

• Android Development Tools

• XCode IDE (OSX only)

Installing Java Runtime Environment, v1.7

Many operating systems have a Java Runtime Environment (JRE) preinstalled. The Eclipse IDE requires a JRE to operate. Using the latest JRE provided by Oracle is preferred. If you will be developing mobile applications using Worklight Studio, the Android Developer Tools specifi-cally require the Oracle JRE and will not work otherwise. All our examples were tested with Oracle JRE7, which you can download from the link in the first step.

1. Browse to http://www.oracle.com/technetwork/java/javase/downloads/index.html .

2. Click the JRE Download button.

3. Accept the license agreement to enable downloading.

4. Select the version appropriate for your operating system.

5. Open the downloaded package, and follow the installation wizard prompts.

6. Verify the JRE installation by opening a command prompt and entering the following command:

java –version

The results should look similar to that in Figure A.1 . Verify that you are running the expected Java version.

Figure A.1 Verifying JRE

Some operating systems, such as Ubuntu Linux, have an administrative command to select the default Java runtime. You might need to restart your system or log in again to see the proper JRE response. Note that if you are using a Mac and you already have an older version of the Java JDK installed, installing a JRE will not update the symlinks appropriately. Instead, download and install a new JDK at the same level.

Page 3: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Development Machine Installation 317

Installing Eclipse Juno IDE, v4.3

The Eclipse Integrated Development Environment (IDE) is the base tool you use here for all development of the web application. Technically, you do the majority of your development and testing using nothing more than a text editor and browser, but there’s no sense in making your life more difficult than necessary. This code for this book was created using Eclipse v4.3 (Juno) for Java EE Developers. Worklight Studio v6 requires Juno or above. These instructions apply to Mac OSX; for other operating systems, such as Linux or Microsoft Windows, the instructions vary slightly.

1. Browse to www.eclipse.org/downloads/packages .

2. Select Juno Packages from the list of versions on the left.

3. Click the link labeled Eclipse for Java EE Developers.

4. Click the Download link for your operating system.

5. Click the Download link for the selected mirror location.

6. Extract the downloaded archive to your desired location.

For example, assume that your development environment will be located at ~/dev for the following sample steps from a command prompt on a Mac OSX system:

mkdir ~/dev

cd ~/dev

tar xvfz ~/Downloads/eclipse-jee-juno-SR2-maxosx-cocoa-x86_64.tar.gz

You should end up with an eclipse installation located at ~/dev/eclipse .

Note: The actual filename might differ as new service releases are created. Of course, if you are using a different OS, your steps will also differ.

7. Start Eclipse using the command ~/dev/eclipse/eclipse .

The first time you launch Eclipse, you are prompted for a workspace location. For this sample, choose ~/dev/workspace. Select to always use this location.

Hint: After you start Eclipse the first time, you can use your desktop environment to lock the launcher icon to your taskbar.

8. Install any available updates. This is a general recommended practice before installing any new plug-ins.

From the main Eclipse menu, click Help > Check for Updates , as in Figure A.2 .

Page 4: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

318 Appendix A Installation Instructions

Figure A.2 Check for Updates

This might take several minutes to complete, depending on the number of repositories configured and updates to install. Restart Eclipse after any updates.

Installing IBM WebSphere Liberty Profile Developer Tools, v8.5.5

The WebSphere Liberty Profile Developer Tools provide support for the WebSphere Liberty profile.

1. From within Eclipse, select Help > Eclipse Marketplace .

2. In the search box, enter websphere and click Go .

3. Within the results list, locate IBM WebSphere Application Server V8.5.5 Liberty Profile Developer Tools for Eclipse Juno and click Install , as in Figure A.3 .

4. On the screens that follow, ensure that all components are selected, accept the license agreement, and click through to completion.

5. Restart Eclipse after the installation has completed.

Page 5: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Development Machine Installation 319

Installing the Source Code for the Book Examples

When the entire development environment has been established, you are ready to import the example source code for the book.

1. Start Eclipse, if it is not already running.

2. Select File > Import .

3. Select General>Existing Projects into Workspace and click Next , as in Figure A.4 .

Figure A.3 Eclipse Marketplace

Page 6: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

320 Appendix A Installation Instructions

4. On the next screen, choose Select Archive File, and then click the Browse button. Locate the project archive to import and click Open. Ensure that all project(s) are selected and click Finish, as in Figure A.5 .

5. Repeat this process for each chapter’s project source as needed.

Figure A.4 Importing existing projects

Page 7: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Optional Development Tooling for Mobile Web Apps 321

Optional Development Tooling for Mobile Web Apps

If you will be developing mobile web applications, you should install the following components. This book does not specifically cover using all the features of these components, but having them available will enable you to work with them to develop hybrid or native applications.

IBM Worklight Studio v6.0

IBM Worklight Studio is the premier development environment for creating mobile hybrid appli-cations. For this installation, you will install the freely available Worklight Studio Developer Edition. This version of Studio does not permit the final deployment of apps, but it enables you

Figure A.5 Select an archive

Page 8: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

322 Appendix A Installation Instructions

to create and test apps using the built-in Mobile Simulator. If you require the final creation and deployment of the application binaries, you must purchase and install the standard Worklight Studio product.

1. From Eclipse, select Help > Eclipse Marketplace .

2. In the search box, enter worklight and click Go .

3. Within the results list, locate IBM Worklight Developer Edition and click Install , as in Figure A.6 .

Figure A.6 Marketplace for Worklight

Page 9: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Optional Development Tooling for Mobile Web Apps 323

4. Ensure that all components are selected, accept the license agreement, and click through to completion.

5. Shut down Eclipse.

6. Update the launch settings for Eclipse. Worklight Studio runs more efficiently with a larger memory allocation. To do this, you need to edit the eclipse.ini file. This file can be found in the following directories:

For OSX: eclipse/Eclipse.app/Contents/MacOS/eclipse.ini

For Windows/Linux: eclipse/eclipse.ini

In that file, update the following values (from >> to):

--launcher.XXMaxPermSize 256m >> 512m

-XX:MaxPermSize=256m >> 512m

-Xms40m >> 80m

-Xmx512m >> 1024m

7. Restart Eclipse and verify that it starts properly.

The next step is to verify proper installation by creating a sample Worklight project and application. You will use this app to test the Android and Xcode installations next.

1. Select File > New > Project . In the New Project dialog box, select Worklight > Work-light Project .

2. Provide a name, such as TestProject , and select Hybrid Application ; then click Next .

3. On the Hybrid Application screen, provide a name for the application, such as TestApp , and click Finish .

Note: You do not need to select a JavaScript toolkit for this app.

Note: Eclipse asks whether you want to switch to the Design Perspective. Respond Yes .

4. Build the app by first opening TestProject and opening the apps folder. Select the TestApp and right-click, and then select Run As > Build All and Deploy .

5. Test the app by opening a web browser and opening the Worklight console, at http://localhost:10080/TestProject/console .

Clicking the Preview as Common Resources link, in Figure A.7 , now opens a new page that simply shows TestApp .

Page 10: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

324 Appendix A Installation Instructions

Figure A.7 Worklight console

Android Development Tools and Eclipse Plug-in

The Android Development Kit enables native compilation of apps into an Android APK file suit-able for installation onto an Android device. It also enables the creation of native emulation for debugging and testing. Finally, it provides tooling to enable remote debugging of apps running on a tethered device from your development machine.

1. Browse to www.oracle.com/technetwork/java/javase/downloads/index.html .

2. Scroll down to SDK Tools Only.

3. Read and accept the license agreement.

4. Download the archive.

5. Extract the archive to desired location (such as ~/dev ).

6. Run the Android tooling (such as ~/dev/android-sdk-linux/tools/android ).

7. Click the Install button if you have any updates to apply.

Page 11: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Optional Development Tooling for Mobile Web Apps 325

The next step is to install the Android ADT Eclipse plug-in.

1. Launch Eclipse and select Help > Install New Software .

2. Click the Add button to add a new repository.

3. Enter the following details:

Name: Android ADT

Location: https://dl-ssl.google.com/android/eclipse/

4. Select Developer Tools and click Next , as in Figure A.8 .

Figure A.8 Developer Tools

Page 12: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

326 Appendix A Installation Instructions

5. Click through the remaining prompts, accept the license agreement, and click Finish .

6. Restart Eclipse after the install completes.

Now that the Android tooling is installed, you need to test it out with the our sample Work-light app.

1. In the Test Worklight project, right-click TestProject > apps > TestApp and select New > Worklight Environment .

2. Check Android Phones and Tablets , and click Finish .

3. Build the app by right-clicking TestProject > apps > TestApp and selecting Run As > Build All and Deploy . Notice that a new project has been created, called TestProject-TestAppAndroid. You’ll use this shortly.

4. If you refresh the Worklight console now, you can see an Android instance of the app that you can preview by clicking the eye icon (see Figure A.9 ).

Figure A.9 Android instance

Again, the results are less than dramatic: All you see is TestApp within an Android simulator, as in Figure A.10 . However, this is enough to be sure that the environment is up and running properly.

Page 13: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Optional Development Tooling for Mobile Web Apps 327

Figure A.10 Browser simulator

Note that the “simulator” is using normal HTML to render the app, with a little Java to simulate device features. This is fine for local development and testing, but it does not accurately test real Android OS behavior. For this, you need to test on the Android “emulator,” which you do in the next step.

5. Test the app using the Android emulator by right-clicking TestProjectTestAppAndroid > Run As > Android Application .

The Android ADT boots up an emulated Android device, deploys the app to it, and shows the results on the screen. You can adjust the Eclipse launch options to modify the behavior so that a certain APK (Android device) is launched. If a physical Android device is attached to your system via a USB cable, the app is deployed and launched directly on that device.

OSX XCode IDE

XCode is an IDE that enables the compilation of apps for IOS-based devices (iPhone and iPad). Xcode is available only on Apple OSX machines. To install Xcode, simply launch the local App Store, search for Xcode, and click Install .

After Xcode is installed, you need to test it with your sample Worklight app.

1. In the Test Worklight project, right-click TestProject > apps > TestApp , and select New > Worklight Environment .

2. Check iPhone or iPad (or both), and click Finish .

Page 14: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

328 Appendix A Installation Instructions

3. Build the app by right-clicking TestProject > apps > TestApp and selecting Run As > Build All and Deploy .

4. If you refresh the Worklight console now, you can see an entry for the IOS device(s) you enabled. You can preview the app in the IOS simulator by clicking the eye icon.

As mentioned for Android, this is not a real test of running under the IOS operating system. For this, you need to test the app directly under Xcode.

5. Test the app under Xcode by selecting TestProject > apps > TestApp > iPhone (or iPad ) and right-clicking Run As > Xcode Project .

The Xcode IDE launches and compiles the app.

In the upper left of the Xcode program, select the emulation target (such as iPhone 6.1 Simulator) and click the Run button, as in Figure A.11 .

Figure A.11 Test project

Note that if a real IOS device is attached to the development machine through a USB cable, a new target device appears indicating this. Selecting this device deploys and launches the app directly on the physical device.

Server Installation

In this section, you install the middleware required to run the application on a standalone server. The server installation would logically be installed onto a dedicated server, but you are free to physically install the middleware directly onto your development machine for local server testing outside your development environment. Just understand that when we say “server,” we are refer-ring to your logical server, regardless of whether it happens to be on the same physical hardware.

Page 15: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Server Installation 329

The following software will be installed on the server:

• IBM WebSphere Liberty profile, v8.5.5

• Apache Derby Database, v10

IBM WebSphere Liberty Profile, v8.5.5

The WebSphere Liberty profile (or simply Liberty) provides a lightweight WebSphere applica-tion server environment to host web applications.

1. Browse to https://www.ibmdw.net/wasdev/downloads .

2. Select WebSphere Application Server Liberty profile and click the Download v8.5.5 button.

3. On the next page, click the Download button for the Liberty profile runtime.

4. Agree to the license terms.

5. Save wlp-developers-runtime-8.5.5.x.jar to your system (for example, in ~/Downloads ).

6. Open a command prompt and change to the directory where you want to install Liberty (such as ~/dev ). Note that Liberty will be installed into a directory named wlp under this directory.

cd ~/dev

7. Run the following command, using the proper location and filename:

java -jar wlp-developers-runtime-8.5.5.x.jar

8. Read and accept the end user license agreement.

9. The installation asks for a target directory. You should be able to accept the default (current) location.

10. The installer extracts the files into a wlp directory and completes.

At this point, WebSphere Liberty is installed and ready to go. Go ahead and verify the installation by creating and starting a new server instance.

1. From the command line, change to the directory where Liberty is installed:

cd ~/dev/wlp

2. Create a new server instance by running the following command:

./bin/server create server1

The server is created under the wlp/usr/servers/ directory.

Page 16: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

330 Appendix A Installation Instructions

3. Check and/or change the default ports to be used by the server, by editing the server’s server.xml file:

View/Edit: ./usr/servers/server1/server.xml

Locate the httpPort attribute of the httpEndPoint node.

4. Start the server using the following command:

./bin/server start server1

5. Open the server instance’s default page using the port defined in the server.xml file. The results should look like Figure A.12 .

Figure A.12 Liberty profile

Apache Derby, v10

Apache Derby is a lightweight, file-based relational database. It is useful for test and devel-opment environments because it is easy to set up and use. It is not appropriate for production environments because it cannot properly manage heavy loads, nor does it have support for high availability scenarios that production applications typically require.

1. Download the Apache Derby bin archive from http://db.apache.org/derby/derby_downloads.html .

Page 17: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Server Installation 331

You should be safe using the latest available version. All the book examples were tested with version 10.8.2.2.

2. Extract the downloaded ZIP file to your desired location (such as ~/dev ).

The archive contains a top-level subdirectory similar to db-derby-10.xx.xx.xx-bin . To make life a little easier, you might want to rename to something simple, such as derby , after extraction. If you do so, note this pathname and adjust the paths you use in building the examples for earlier chapters.

3. Set the DERBY_HOME and the PATH environment variables pointing to your new derby directory (for example, ~/dev/derby ).

4. Set your required paths. The procedure to do this varies by OS.

For OSX/Linux, you typically edit your ~/.profile and add entries similar to the fol-lowing; then you log off or on to pick up this new environment setting.

export DERBY_HOME=~/dev/derbyexport PATH=$PATH:~/dev/derby

5. Create a connection definition in Eclipse:

a. Open the Data Source Explorer view.

b. Click the New Connection Profile icon, as in Figure A.13 .

Figure A.13 Connection profile

c. Select Derby, change the name to Derby, and click Next .

d. Click the New Driver Definition (target) icon (see Figure A.14 ).

e. Select Derby Embedded JDBC Driver and select the highest version defined. An error might appear saying that the driver JAR cannot be found. You’ll fix this next.

f. Click the JAR List tab, select the derby.jar file, and click the Edit JAR/Zip button.

Page 18: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

332 Appendix A Installation Instructions

g. Click Browse and locate the real derby.jar file ( ~/dev/derby/lib/derby.jar ); open it and click OK .

When the driver is properly defined, you return to the main connection page in Figure A.14 .

h. Update the database name and location to suit your tastes (such as ~/dev/derby/db/MyDB ), and click Finished .

Figure A.14 Create a new driver

Page 19: Modern Web Development with IBM® WebSphere®: Developing ...public.dhe.ibm.com/software/dw/dwbooks/modernweb... · The Android Development Kit enables native compilation of apps

Summary 333

Downloading and Installing Example Source Code

As noted above, all the example code for this book, as well as the latest version of the installation instructions you are reading, can be found here:

http://www.ibm.com/developerworks/dwbooks/modernwebdev/index.html

All the example code is contained within individual Eclipse Project Interchange files, one for each chapter, which can be obtained from this URL. After you have located the files on the web, download them to your local machine. Then you can import them into Eclipse and begin browsing them. You do this with Eclipse by selecting File > Import Menu. Expand the general section in the wizard, and select existing projects into workspace. After you click Next, select the archive file option and then select the appropriate zip file for that chapter; for instance, the file for the sample code from Chapter2 is Chapter2Example.zip. The text of each Chapter tells you which file to look for, and what the contents of the file are after you install it.

Summary

This appendix has provided instructions for installing both development tools and server-side middleware needed to create the application code defined in this book. It was tested on three primary platforms—OSX, Linux, and Windows 7—for completeness and accuracy. Obviously, product versions change frequently, and you must use proper judgment (and read compatibility guides) to ensure that newer products can interoperate. If you have any issues with the installa-tion of any of these products, either post a message to the appropriate message board on IBM developerWorks or contact your IBM marketing representative for assistance. Good luck and have fun!