Академический Документы
Профессиональный Документы
Культура Документы
When downloading the three components listed below, be sure to obtain the latest
stable version.
Contents at a Glance:
1. Download and install Java SE JDK
2. Download and install WildFly server
3. Download and install NetBeans
4. Add Wildfly server to NetBeans
5. Assign WildFly to a NetBeans Project
6. Create a Web Application Project in NetBeans
7. Run a Web Application in NetBeans
8. Creating Class Files and Packages in NetBeans
9. Alternative Method to Add WildFly (Plugin)
http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-
2133151.html
Page 1 of 34
JDK-WildFly-NetBeans Setup Local
Select Next (Change is selected to show the non-standard setting for the JDK).
Page 2 of 34
JDK-WildFly-NetBeans Setup Local
This is what a non-standard installation location looks like (dont do this step):
The next step asks for the location of the JRE. It should also be installed to the C:\
drive as shown.
Page 3 of 34
JDK-WildFly-NetBeans Setup Local
TheSuccess dialog should appear after the installation. Select Next Steps.
Selecting Next Steps above opens a web page with the following diagram. You
will want to bookmark this page for future reference.
Page 4 of 34
JDK-WildFly-NetBeans Setup Local
The latest stable JDK, including the JRE, has been installed. We are now ready to
install WildFly and NetBeans.
Page 5 of 34
JDK-WildFly-NetBeans Setup Local
Move the .zip file wildfly-8.1.0.zip to the folder where you would like to install the
server. Right-click and select | Extract All. The current location will appear.
Unzipping can take a while. Note: I install to flash drives to maintain multiple
environments (hence the N:\). However, I highly recommend that development
tools be installed to the local C:\ drive.
Page 6 of 34
JDK-WildFly-NetBeans Setup Local
I get the error that the expected version of the JDK does not exist. I installed a later
version of the JDK and will need to make the adjustment to the JAVA_HOME
environment variable.
Page 7 of 34
JDK-WildFly-NetBeans Setup Local
Open browser and type localhost:8080 in the browser URL address box. You
should see the message: Welcome to WildFly Your Wildfly is Running.
Page 8 of 34
JDK-WildFly-NetBeans Setup Local
Click Administration Console (but no users added yet to access admin). Add users
by running wildfly-8.1.0.Final\bin\add-user.bat (double-click to run). Choose
Management user (a), enter your username: myusername and your pw: mypasswd.
Just select enter for no group, yes for correct and no for slave process.
Page 9 of 34
JDK-WildFly-NetBeans Setup Local
The WildFly Admin page opens. We will come back to the local Admin page in
the tutorial MySQL in WildFly Setup Local. In that tutorial, we will register the
mysql...jar file with the WildFly server using the jboss-cli.bat tool. Then we will
use WildFly Admin to add the datasourse within WildFly. To take a glimpse or the
process to add a datasoure select Configuration.
Page 10 of 34
JDK-WildFly-NetBeans Setup Local
test the connection as we create it. To test the connection, we need MySQL
running and we need the database created in MySQL that is part of the datasource.
Page 11 of 34
JDK-WildFly-NetBeans Setup Local
Why NetBeans? While there are a number of other popular IDEs for Java EE
development such as IntelliJ IDEA and Eclipse, a Feb2014 Java.net survey
suggests that NetBeans remains the most popular Java IDE:
https://www.java.net/poll/i-do-most-my-coding-using
NetBeans releases are in sync with SE JDK and EE JDK releases. NetBeans is also
managed by Oracle, the same company that manages the Java updates.
Select the Java EE package. Also, be sure to select the latest stable version (8.0.1 is
the latest stable at the time of this writing). If version 9.x is the latest stable,
download and install it.
Page 12 of 34
JDK-WildFly-NetBeans Setup Local
Move the netbeansexe to the location where you would like to install. I moved it
to N:\.
Page 13 of 34
JDK-WildFly-NetBeans Setup Local
Accept the defaults on the installation and JDK locations. Again, I am coding on
the edge by not developing from C:\. Not recommended. Select check for updates
in the next dialog and then Next. Installation begins.
Page 14 of 34
JDK-WildFly-NetBeans Setup Local
In the Services pane, R-click Servers and select Add Server. See Plugin method
below if WildFly server does not appear in list of available servers.
Select Wildfly Application Server. NOTE: If WildFly does not appear in the list of
available servers, perform the steps in the Alternative Method to Install WildFly
(via Plugin) at the end of this tutorial and then come back to Add Server above.
Page 16 of 34
JDK-WildFly-NetBeans Setup Local
Select WildFly Application Server (which is currently the only server recognized
by NetBeans on this machine). Select OK. Now WildFly is assigned as the
projects server and will start when the project is run (if the server is not already
running).
Page 17 of 34
JDK-WildFly-NetBeans Setup Local
Set the name and location of your web application. Name the project ROOT. In the
tutorial WildFly Setup Remote we will use this project to create and upload the
home page for our remote web site. As previously mentioned, I recommend
installing development tools and projects on your C:\ drive. I place projects on my
RAID 1, mirrored G:\ drive which is a local logical drive.
Page 18 of 34
JDK-WildFly-NetBeans Setup Local
If this is the first time creating a web application in this installation of NetBeans,
you may receive a warning at the bottom of the next dialog box.
Click the Add button to register a WildFly server using the appropriate settings
previously covered in this tutorial.
Accept the default settings in the next window if like shown and select Next. No
frameworks are required for this project so none should be selected in the next
window. Select Finish.
Page 19 of 34
JDK-WildFly-NetBeans Setup Local
A starting index.html page is created like below. Close and delete that file (R-click
| Delete). We code the replacement next.
Create the file index.jsp by R-Clicking on the project name | New | JSP and name it
index.jsp. This will be the home page of our remote site. Code the content shown
and make the appropriate replacements on lines 6 and 12.
Page 20 of 34
JDK-WildFly-NetBeans Setup Local
With the Projects tab selected a logical view of the project is displayed.Your
project structure should look like the following.
Page 21 of 34
JDK-WildFly-NetBeans Setup Local
However, the ROOT project is a bit unique and needs to be started differently. If
we attempt to run the ROOT project like all others, we will see the following web
page due to the ROOT extension added to the URL.
Page 22 of 34
JDK-WildFly-NetBeans Setup Local
With the ROOT project, we need to start the WildFly server first, deploy the .war
file, and then access the ROOT project by localhost:8080 in the URL address
box (without the ROOT extension which is implied). Start the WildFly server by
Services | WildFly Application Server | Start.
The WildFly server can also be started by selecting the Run Server button in
the bottom Output panel.
If a web server has NOT been assigned to the project, R-click the project name in
the Project window to specify the server and select Specify Web Server at the
bottom of the menu or in Properties.
Page 23 of 34
JDK-WildFly-NetBeans Setup Local
The JDK installation includes a public and a private JRE. When the JRE is first run
from a new installation you may see the Windows Security Alert as shown below. I
strongly recommend that the Private networks option be selected for the
development environment to operate more securely. The Name: specified in the
dialog may be NetBeans IDE instead of Java as shown. In either case, select
Private networks and then Allow access.
Page 24 of 34
JDK-WildFly-NetBeans Setup Local
We need to replace the default ROOT content with our own which we do by R-
clicking the project name | Deploy.
Now, our ROOT.war file is deployed to WildFly which can be verified with the
local WildFly Admin app (localhost:9990) | Runtime | Manage Deployments.
Page 25 of 34
JDK-WildFly-NetBeans Setup Local
Page 26 of 34
JDK-WildFly-NetBeans Setup Local
Navigate to your project dist folder. You will see the .ROOT.war file. This is the
file that will be published to your student website in the WildFly Setup Remote
tutorial.
Page 27 of 34
JDK-WildFly-NetBeans Setup Local
package to contain Java class files, R-click on the project name, select New, and
then Java Package The dialog box below appears. We will use the name college.
Notice that NetBeans places the package in the standard location of
src\java\{packagename}.
The package is created in the location shown in the different views. Recall that the
Projects tab on the left shows a logical configuration of the project while the Files
tab displays the actual file and folder structure.
Page 29 of 34
JDK-WildFly-NetBeans Setup Local
Note: instead of creating a package first and then adding class files to the package,
you can create a package at the same time as a class file by selecting Java class
from the New menu.
After the package is created, you can add a Java class file to the package by R-
clicking the package name and selecting Java class The class file is named
Student in the example, placed in the college package, and in the path shown.
The college package now contains the Student.java class file. By the way, the
globe icon identifies asg09 as a web project.
Page 30 of 34
JDK-WildFly-NetBeans Setup Local
WildFly creates the following starter file Student.java from the .java template.
Recall from the ITSE 2317 course material that an import statement like that below
is used to import the package and its class files for use in a .jsp.
Page 31 of 34
JDK-WildFly-NetBeans Setup Local
After testing the project and when ready to upload to the student website, R-click
the project and select Clean and Build.
Page 32 of 34
JDK-WildFly-NetBeans Setup Local
With a successful Clean and Build, NetBeans automatically creates the dist (short
for distribution) folder and places the asg09.war file in the asg09/dist folder.
The asg09.war file contains all files, in their proper locations, required for a servlet
container to run the website. It is this file that should be uploaded to the student
website per the instructions in the WildFly Setup Remote tutorial. Reminder: this
version of asg09 is not the actual project assignment. See Bb for asg09 assignment
instructions.
You are now ready to code your projects asg09-asg12. Good luck with your efforts
and enjoy the process. Java EE is challenging but the rewards are worth the
commitment.
Page 33 of 34
JDK-WildFly-NetBeans Setup Local
Only need to perform the steps in this section if the WildFly server did not appear
when selecting Add Server above. Open NetBeans and select Tools | Plugins..
Check for Updates on the Updates tab. Then, on the Available Plugins tab, check
the box next to the WildFly Server item and select Install. Note: WildFly
Application Server came off both lists of Available and Installed plugins after I
installed it. Also, if WildFly does not appear on the Available Plugins list then it
should appear on the Services | Server | Add Server menu.
Page 34 of 34