17
IBM Press Template Examples, 1 Appendix A Installation Instructions This appendix covers the installation of all the software required to develop modern 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 developed throughout this book. Although this is a step beyond the standard development of the application, we feel that it is important to be able to deploy the final product onto a separate hosting server. The authors would like to thank Bhargav Perepa for helping make this update possible by taking the screenshots for the Mac version of this revision. Thanks Bhargav! 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 procedure 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 http://www.ibm.com/developerworks/dwbooks/modernwebdev/index.html. The page you are now reading is the version of the instructions updated in January 2015 for the latest supported versions of the tools. This chapter is a replacement for the one printed in the first edition of the book. 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: o Java Runtime Environment, v1.7 o Eclipse Luna IDE, v4.4.1 o IBM WebSphere Liberty Profile Developer Tools for Luna o Source code for the book In addition, we cover installation of the following optional tools for mobile development:

Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

  • Upload
    others

  • View
    1

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 1

Appendix A Installation Instructions

This appendix covers the installation of all the software required to develop modern 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 developed throughout this book. Although this is a step beyond the standard development of the application, we feel that it is important to be able to deploy the final product onto a separate hosting server.

The authors would like to thank Bhargav Perepa for helping make this update possible by taking the screenshots for the Mac version of this revision. Thanks Bhargav!

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 procedure 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 http://www.ibm.com/developerworks/dwbooks/modernwebdev/index.html. The page you are now reading is the version of the instructions updated in January 2015 for the latest supported versions of the tools. This chapter is a replacement for the one printed in the first edition of the book.

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:

o Java Runtime Environment, v1.7 o Eclipse Luna IDE, v4.4.1 o IBM WebSphere Liberty Profile Developer Tools for Luna o Source code for the book

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

Page 2: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 2

o IBM MobileFirst Platform Studio, v6.3.0 o Android Development Tools o XCode IDE (OSX only)

Installing Java Development Kit, 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 IBM MobileFirst Platform Studio, the Android Developer Tools specifically require the Oracle JRE and will not work otherwise. All our examples were tested with Oracle JDK 1.7, 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 corresponding level. Note: If you have JDK 1.8 already installed then unfortunately you are also going to have to also install an additional JDK 1.7. Note that this is a silent install – the second JDK will be installed but java –version will still show that you have version 1.8 installed. After installing the additional JDK 1.7, then you have to set it up in Eclipse. First, use the command “/usr/libexec/java_home –verbose” to give you the location of the JDK 1.7 install . Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and press

Page 3: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 3

the Add button to install the 1.7 JDK into Eclipse. You can then change the change the compiler settings to refer to the 1.7 JDK.

Installing Eclipse Luna IDE, v4.4.1

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 tested using Eclipse v4.4.1 (Luna) for Java EE Developers. IBM MobileFirst Platform Studio v6.3.0 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 Luna Packages from the list of versions on the left. 3. Click the link labeled Eclipse IDE 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-luna-SR1-macosx-cocoa-x86_64.tar 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: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 4

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 for Luna 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 Luna and click Go. 3. Within the results list, locate IBM WebSphere Application Server

Liberty Profile Developer Tools for Luna and click Install, as in Figure A.3.

Page 5: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 5

Figure A.3 Eclipse Marketplace

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

5. Restart Eclipse after the installation has completed.

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.

Page 6: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 6

2. Select File > Import. 3. Select General>Existing Projects into Workspace and click Next, as in

Figure A.4.

Figure A.4 Importing existing projects

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.

Page 7: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 7

Figure A.5 Select an archive

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

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 MobileFirst Platform Studio v6.3.0 IBM MobileFirst Platform Studio (formerly named IBM Worklight Studio and referred to as Worklight Studio in the text of the book) is the premier development environment for creating mobile hybrid applications. For this installation, you will install the freely available MobileFirst Platform Studio 6.3. This version of Studio does not permit for production use of the apps, but it enables you to create and test apps using the built-in Server and Mobile Simulator. If you require the final creation and deployment of the application binaries, you must purchase the standard MobileFirst Platform Foundation product.

1. From Eclipse, select Help > Eclipse Marketplace. 2. In the search box, enter MobileFirst and click Go. 3. Within the results list, locate IBM MobileFirst Platform Studio 6.3.0

and click Install, as in Figure A.6.

Page 8: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 8

Figure A.6 Marketplace for MobileFirst Platform Studio

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. IBM MobileFirst Platform Studio

runs more efficiently with a larger memory allocation. To do this, you need to edit the

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 IBM MobileFirst Platform project and application. You will use this app to test the Android and Xcode installations next.

Page 9: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 9

1. Select File > New > Project. In the New Project dialog box, select MobileFirst > MobileFirst 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. Select the TestProject and right-click then select Run As > Run on MobileFirst Development Server.

5. Test the app by opening a web browser and opening the MobileFirst Studio console by selecting TestProject then right-clicking and selecting Open MobileFirst Console, or opening a browser at http://localhost:10080/worklightconsole/index.html#TestProject,catalog

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

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 suitable 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 http://developer.android.com/sdk/index.html. 2. Scroll down to SDK Tools Only.

Page 10: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 10

3. Read and accept the license agreement. 4. Download the archive. 5. Extract the archive to the desired location (such as ~/dev). 6. Run the Android tooling (such as ~/dev/android-sdk-

linux/tools/android). 7. It will ask you for the location at which you downloaded the Android

toolng (e.g. something like ~/Users/you/dev/android-sdk-macosx). It may also ask you to download some updates. Enter the location when it prompts you. Click the Install button if you have any updates to apply and also allow it to perform the downloads.

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 11: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 11

5. Click through the remaining prompts, accepting 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 the our sample Worklight app.

1. In the Test IBM MobileFirst Worklight project, right-click TestProject > Apps > TestApp and select New > IBM MobileFirst 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 TestProjectTestAppAndroid. You’ll use this shortly.

4. If you restart the MobileFirst Studio console now, you can see an Android instance of the app that you can preview by clicking the eye icon. Again, the results are less than dramatic: All you see is TestApp within an Android simulator, as in Figure A.9. However, this is enough to be sure that the environment is up and running properly.

Figure A.9 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.

Page 12: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 12

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, 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 > MobileFirst Environment.

2. Check iPhone or iPad (or both), and click Finish. 3. Restart the MobileFirst console by selecting TestProject, right-clicking

and selecting Open MobileFirst Console. You should 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.10.

Page 13: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 13

Figure A.10 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.

Page 14: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 14

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 referring to your logical server, regardless of whether it happens to be on the same physical hardware.

The following software will be installed on the server:

[lb] IBM WebSphere Liberty Profile, v8.5.5.4 [lb] Apache Derby Database, v10

IBM WebSphere Liberty Profile, v8.5.5.4 The WebSphere Liberty Profile (or simply Liberty) provides a lightweight WebSphere application 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 15: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 15

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 (use sudo to start or stop a server in superuser permitted mode of operation to start or stop a server): sudo ./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.11.

Figure A.11 Liberty Profile

Apache Derby, v10 Apache Derby is a lightweight, file-based relational database. It is useful for test and development 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.  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

Page 16: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 16

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 following; then you log off or on to pick up this new environment setting. export DERBY_HOME=~/dev/derby export PATH=$PATH:~/dev/derby

5. Create a connection definition in Eclipse.  Open the Data Source Explorer view. Click the New Connection Profile icon, as in Figure A.12.

Figure A.12 Connection profile

Select Derby, change the name to Derby, and click Next. Click the New Driver Definition (target) icon (see Figure A.14). 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. Click the JAR List tab, select the derby.jar file, and click the Edit JAR/Zip button. 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.13.

Page 17: Appendix A - public.dhe.ibm.compublic.dhe.ibm.com/software/dw/dwbooks/modernweb... · Next, go into Eclipse and make the menu selection Eclipse>Preferences>Java>InstalledJRE’s and

IBM Press Template Examples, 17

Figure A.13 Create a new driver

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

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. This version of the appendix was tested on Mac OSX 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 installation 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!