Java EE 8 Hands On Lab
Table of contents
- Initial setup
- Exercise 1 : JSON-B 1.0 and Bean Validation 2.0
- Exercise 2 : Jakarta EE Security API
- Exercise 3 : Servlet 4 and HTTP/2 Support
- Exercise 4 : JAX-RS 2.1 and CDI 2.0
- Credits
Initial setup
During this "Bring Your Own Laptop" Lab, you will use NetBeans 8.2 and GlassFish 5, the open source Java EE reference implementation to test some of the new Java EE 8 APIs.
GlassFish 5 is today the only Java EE 8 compatible application server. Over time, this will change as implementors will add support to Java EE 8 to their application servers. This lab will then also work on those application servers.
Install Java SE 8 JDK
If you don't have a recent JDK 8 installed on your laptop, download and install Java SE 8 Development Kit 8u144.
Install GlassFish
Download the final version of GlassFish 5.0. To install it, just unzip the archive into a target directory. Take a moment to note the directory where GlassFish 5 is installed as this path will be required in the next step.
You can now start GlassFish 5...
cd glassfish5
bin/asadmin start-domain domain1
After a few seconds, you should see the following...
Waiting for domain1 to start ......
Successfully started the domain : domain1
domain Location: /Users/davidd/work/glassfish5/glassfish/domains/domain1
Log File: /Users/davidd/work/glassfish5/glassfish/domains/domain1/logs/server.log
Admin Port: 4848
Command start-domain executed successfully.
You can now connect to the GlassFish Admin Console on http://localhost:4848.
Install and configure NetBeans
If you have NetBeans 8.2 with Java EE support already installed on your machine, you can go directly to the NetBeans configuration step.
Install NetBeans
Download NetBeans 8.2, make sure to download the "Java EE" bundle ("All" will also work). You can now install and launch NetBeans.
Configure NetBeans
NetBeans 8.2 comes with GlassFish 4.x (Java EE 7), we will now reconfigure NetBeans to use GlassFish 5 (Java EE 8) instead.
In NetBeans, select "Services" tab, "Servers" and right click to select "Add Server..."; this will open an "Add Server Instance" window. Name your instance, ex. "GlassFish 5" and click Next. Now in the install location, enter the directory where you have installed GlassFish 5 (see previous step). If everything goes well, NetBeans will confirm that a GlassFish 5.0 installation was found, you can now click "Next" and "Finish" to accept the default values.
You should now see your "GlassFish 5" instance under "Servers". Right click on it, you can now "Start" it if it is not started yet. After a few seconds you should see that GF5 is started in the NetBeans Output window at the bottom.
You can also connect to the GF Admin console (http://localhost:4848] to confirm that GF is up and running.
Clone the Lab GitHub repository
The only thing you have to do is to clone the Lab GitHub repository on your machine.
In NetBeans, choose "Team", "Git", "Clone..."
... and enter the URL (https://github.com/javaee/j1-hol.git) of the Lab GitHub repository to clone as below, keep the other default values.
Select "Open Sources in Favourites" and "Finish". You can check the clone operation in the "Output" windows, the cloned repository should also appear under the "Favourites" tab.
You are now all set to do the first exercise!
Credits
This Java EE 8 Hands-on-Lab has been developed by David Delabassee (Java EE Evangelist, Oracle), David Heffelfinger (Principal Consultant, Ensode Technology, LLC) and Michael Nascimento Santos (CEO, Improving) for JavaOne 2017.