Setup PRJ301 Tools
Setup PRJ301 Tools
Setup PRJ301 Tools
To develop and deploy a java web application on WINDOW, you need to follow 6 below instructions:
Contents
Instructions for setting up the environment for java web PRJ301 (updated)..............................1
1. Installing JDK 17........................................................................................................................2
2. Installing Apache Tomcat 10.1.x...............................................................................................3
3. Installing Apache NetBeans IDE 17..........................................................................................8
4. Integrating Apache NetBeans IDE 17 with Apache Tomcat..................................................9
5. Create Java Web project, Servlet and Debug........................................................................11
6. Working with JSTL..................................................................................................................14
7. Working with JDBC.................................................................................................................15
1. Installing JDK 17
https://www.oracle.com/java/technologies/downloads/
Select
JDK 17 -> Window -> x64 Installer, then click to the corresponding link to start downloading.
The downloaded file is jdk-17_windows-x64_bin.exe. Running this file, jdk 17 will be installed and
located at: C:\Program Files\Java\jdk-17
2. Installing Apache Tomcat 10.1.x
https://tomcat.apache.org/download-10.cgi
Click on the item: 32-bit/64-bit Windows Service Installer (pgp, sha512)
to download Tomcat.
You will get the file apache-tomcat-10.1.17.exe . Run this file to install Tomcat.
Configuration Options:
For the simplicity, you can keep default values for ports (-1 and 8080), Tomcat10.1 for Service Name. You can
use "sa" for both User Name and Password as shown below:
Click “Next”, then the installer will ask you for JDK-17 folder. Basically, the installer can automatically detect
JDK-17 folder, but in the case it cannot, you can add it manually.
Now you can open Services window to see the installed Tomcat:
(You can open Services window by typing Services in Search text field in the Task bar or press window+R)
3. Installing Apache NetBeans IDE 17
https://netbeans.apache.org/front/main/download/nb17/
During your installation, remember to select JDK 17 (just in case, you have more than one version of Java).
After installation, run Netbeans 17, File > New Project > Java with Ant > Select Web Application (It is disabled
by default, just select it, netbeans will automatically enable the project template).
, just click “Continue” button. This step aims to allows your account to access the Apache Tomcat folder for
further tasks.
+ Open Netbeans, on the menu bar, Window > Service (Ctrl + 5) > select Service panel as following:
Server > Right click > Add Server > Apache Tomcat and TomEE >
Here you can create your username and password, then finish. Now you can work with Java Web project in
netbeans 17.
Create simple Java web applicationto to test whether NetBeans and Tomcat work together well:
If you get an error related to “CATALINA_base is Invalid”, check the first step.
Run testWeb1 just created,we get the error below:
In-place deployment at D:\aJavaEXS_17\testWeb1\build\web
deploy?config=file%3A%2FC%3A%2FUsers%2FAdmin%2FAppData%2FLocal%2FTemp
%2Fcontext1725998469679540228.xml&path=/testWeb1
FAIL - Failed to deploy application at context path [/testWeb1]
D:\aJavaEXS_17\testWeb1\nbproject\build-impl.xml:1030: The module has not been deployed.
See the server log for details.
BUILD FAILED (total time: 0 seconds)
Errors related to Tomcat will be logged to “C:\Program Files\Apache Software Foundation\Tomcat 10.1\logs”,
check the catalina**** file for the detail logs.
Open window services, we see that Tomcat is running:
Select Allow access buttons then run testWeb1 again, we can see that it
runs successfully and the resulting screen looks like below:
5. Create Java Web project, Servlet and Debug.
To create a new java web project: File > New Project > Java with Ant> Java Web > Web Application (See the
below figure)
Add library sqljdbc42.jar and jaxb-api-2.1.jar to be able to perform jdbc related operations in java.
Download sqljdbc42.jar và jaxb-api-2.1.jar in internet.
Or: setups
Sau khi add thư viện thì trong project sẽ như sau: