IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
1
IBM Bluemix – http://ibm.biz/bluemixph
A platform where developers can act like kids in a sandbox —except this box is enterprise-grade.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
This laboratory exercise demonstrates how to connect Eclipse to Bluemix and upload an application to Bluemix using Eclipse.
Prerequisite
Item Comment
Eclipse do the “Setting-up Laboratory Environment” (section: Installing Eclipse) laboratory exercise to install Eclipse
Bluemix Account do the “Creating a Bluemix Account” laboratory exercise if you do not have a Bluemix account
Downloading Sample WAR File
1. Go to a GitHub repository (https://github.com/ibmjstart/bluemix-java-postgresql-upload/releases)/ 2. Click the “PostgreSQLUpload.war” button to download the WAR file. Save the WAR file under
c:\bluemixtemp.
Note: There might be several versions of the WAR file. Download v1.1.
3. The PostgreSQLUpload WAR file is a sample Java web application that uses a PostgreSQL database. It asks for a text file from user and saves each line in the text file as a row in a table in the database.
Note: Once you have completed this laboratory exercise, you may use the procedure as a basis to upload and your own WAR file to Bluemix using Eclipse.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
2 Download Sample WAR File
1. Launch Eclipse. Close the “Welcome” tab.
2. In the menu, click Help->Eclipse Marketplace.
3. In the “Eclipse Marketplace” search for “cloud foundry”. Look for the item titled: "Cloud Foundry Integration for Eclipse x.x.x". Click “Update” (or “Install”) to update (or install) Cloud Foundry Integration for Eclipse.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
3 Setting-up Bluemix Server
1. In the bottom window section of Eclipse, select the Servers tab.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
4 3. In “New Server: Define a New Server” window, select Pivotal->Cloud Foundry. Click “Next”.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
5 4. In “New Server: Cloud Foundry Account” window, click “Manage Cloud”.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
6 6. In “Add and validate a Cloud URL” window, enter “Bluemix” in the name field and
https://api.ng.bluemix.net in the URL field. Click “Finish”.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
7 8. In “New Server: Cloud Foundry Account” window, make sure that the URL is “Bluemix –
https://api.ng.bluemix.net”. Enter your Bluemix username and password in the “Email” and “Password” fields, respectively. Click “Validate Account”. Once the account is validated, click “Finish”.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
8 Import the WAR file to Eclipse
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
9 2. In the “Import: Select” window, select Web->WAR File. Click “Next”.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
10 3. In the “Import: WAR Import” window, click “Browse”.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
11 4. In the “Open” window, select the PostgreSQLUpload.war file under the folder c:\bluemixtemp. Click
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
12 5. In the “Import: WAR Import” window, click “Finish”.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
13 Uploading the Application in Bluemix
1. In the bottom window section of Eclipse, select the Servers tab.
2. Right-click on the Bluemix server (Pivotal Cloud Foundry) and click “Connect”.
Note: If the “Connect” entry is disabled and the “Disconnect” entry is enabled, it means that Eclipse is already connected to the Bluemix server.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
14 3. Right-click on the Bluemix server (Pivotal Cloud Foundry) and click “Add and Remove”.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
15 5. In the “Add and Remove” window, click “Finish”.
Note: Aside from PostgreSQLUpload, it is possible that there are other applications listed in the right pane. These are the applications that are currently available in your Bluemix account. In the
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
16 6. In the “Application: Application details” window, enter “textfileuploader-<your name>” in the Name
filed. Click “Next”.
7. In the “Application: Launch deployment” window, take note of the “Deployed URL” field. Click “Finish”.
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
17 8. In the bottom window section of Eclipse, select the Console tab (if necessary). Wait for the “The
server defaultServer is ready to run a smarter planet” message to appear.
9. Open a browser. Access your uploaded application (http://textfileuploader-<you name>.mybluemix.net/)
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
18 Edit Application and Redeploy in Bluemix
1. In the “Project Explorer” expand PostgreSQLUpload->Java Resources->com.ibm.bluemix.samples. Double-click PostgreSQLClient.java to open it. Scroll-down until you see the createTable() method.
2. You can modify this method to create the tables you need for your application. You can modify also other files as needed.
3. Assuming that you have done the necessary modifications, you can redeploy your application. 4. In the bottom window section of Eclipse, select the Servers tab. Expand the Bluemix server (Pivotal
Cloud Foundry).
IBM Bluemix Tutorial
Connecting Eclipse to Bluemix v2.0
19 6. In the bottom window section of Eclipse, select the Console tab (if necessary). Wait for the “The
server defaultServer is ready to run a smarter planet” message to appear.