The laboratory exercise for this module to install Eclipse and then develop a one or two static HTML pages
Level of Difficulty: 2 (moderately easy)
Estimated time: 30 minutes
Pre-requisites:
Eclipse has been pre-installed on the lab workstations. You can start this via Applications → Programming → eclipse-oracle
You MUST use the "oracle" version of eclipse, not the "wtp" verson.
You now should see the Eclipse workspace launcher start.
Leave the default (workspace), just be aware that you can change this and Eclipse will automaticallycreate a directory for you with that name in your home directory.
You should click on the X on the [Welcome] tab to get the following workspace window:
This is the main Java EE "perspective". If you don't see this, click on the Window → Open Perspective → Other → Java EE (default)
Or click the perspective button on the left-hand side of the current perspective and select the 'Java EE' perspective (Please look at the screenshot above).
Before you begin the setup instructions below, you will probably find ithelpful to rearrange your windows so that this browser window and your Eclipse workspace windoware side-by-side. This will save you flipping back and forth between theinstructions and eclipse.
Before creating a new Java EE project, we need to add a Java EE application server that is weblogic for this course.
To add a new server, Click on the Window → Preferences
Expand the 'Server' category → Select 'Runtime Environments' → Click the Add button
Select the Oracle WebLogic Server 11gR1 PatchSet 2 under the Oracle category → Click the Next button
Enter WebLogic home and Java home.
WebLogic Home: /opt/oracle-middleware/wlserver
Java Home: /usr/java/default
If the 'Finish' button is not enabled, click the 'Back' button.
Then click the 'Next' button again → Now the 'Finish' button is enabled → Click the Finish button
As you can see, the 'Oracle WebLogic Server' is added to the Server Runtime Environment.
Click the OK button
Select the 'Server' view → Right-click inside the Server View panel → New → Server
Click the Next button
In the "Domain directory" box, enter /home/your_username/weblogic
(Your user name is your student number).
Oracle WebLogic Server 11gR1 PatchSet 2 is added to the Server view
To create a new Java EE project, we are going to create a Web application first.
Step 1: From the Project Explorer:, Right Mouse Button click→ New→Project → Dynamic Web Project
(alternatively: Choose the File-→New→Other→Web→Dynamic Web Project )
Enter the project name: labs
Make sure the Target runtime is Oracle WebLogic Server 11gR1 Patch Set 2 and Dynamic Web Module version is 2.5 and a new default configuration for Weblogic. Depending on your server runtime chosen, Eclipse will display different information.
Our first main exercise will be to just create a plain old web page.
The next challenge is to create HTML files for our web site.
From Project Explorer select Labs
Now Right Mouse Button click -> New > HTML
→
(note: WebContent is highlighted)
We choose a filename: index.html
& press [Next]
At the Select HTML Template panel: HTML 4.01 Transitional & press [Finish]
You can now see it generates a HTML page which you can edit.
Before you can start testing, you need to define a server to run this web page one. We will use Weblogic as a normal web server for the moment.
Select the labs project in the Project Explorer and press the Right mouse button
Select Run As -> Run on Server
You will get a Run on server panel:
If you have successfully created your server in a previous step, selectChoose an existing server and Press [Finish].
Leave the defaults. If you have more than 1 server defined, this is where you can choose which server to test your page on. In our case, we will just use Weblogic, so select [x] Always use this server when running this project
Press [finish] to continue.
You should get weblogic server starting in a new window - see the Console view on the bottom right hand side for % progress)
Wait till the <Server started in RUNNING mode>
message appears.
A browser window should appear in eclipse with your web page!
You can add many extra pages. Try make them link eg: <a href=..">
If you get an error message saying "Publish was cancelled" this could be because your server and project is already running.
If this is the case, you could start the server manually, by pressing the green arrow
If you double-click on the server name (eg: "Oracle Weblogic Server V10.3" above), you can also get the server configuration settings.
This will allow you to manually remove (ie: "undeploy" ) a project which may be preventing weblogic from starting (for example, "labs" )
If you need to restart the internal browser for any reason,
use Window -> Show View -> Other -> General -> Internet Web Browser
Note: it is better to start an external browser, as the internal browser may not support all the latest browser functionality.
Test to see that your new application works. In a browser, open a URL like:
http://localhost:7001/labs/index.html
Note that in most cases you will have a "Context root" which is effectively a subdirectory. So if our web Context root was, for example, labs, our URL would be: http://localhost:7001/labs/index.html
Notes:
For an introduction to WAR files, JAR files and EAR files, read
This will give you a head start on some of the later course material.