Nothing Special   »   [go: up one dir, main page]

Setup PRJ301 Tools

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 14

Instructions for setting up the environment for java web PRJ301 (updated)

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.

When the below window appear, click the Install button:


The final window:

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).

4. Integrating Apache NetBeans IDE 17 with Apache Tomcat.


+ First, open the Apache Tomcat folder:
By default, it is located at: C:\Program Files\Apache Software Foundation\Tomcat 10.1
The system may ask you to grant permission

, 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:

Right click on Tomcat and select Stop, then run


testWeb1 again, some windows appear:

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)

/// LET DO IT, IN THE SESSION OF SERVLET


Once you create new Servlet via Netbeans template file. By default, netbeans using javax, which is not included
in Jarkata EE platform equipped by Tomcat 10. Just need to replace all javax by Jakarta package, then
everything will be compiled.

Refer to https://tomcat.apache.org/ for more detail


you can also edit the template file for further tasks.
// For one who cannot start debugging mode with apache tomcat 10. Open task manager window then kill the
process of Java SE.
Check the video: https://youtu.be/9Zcy7yWNAm4
OR
Open window PowerShell, type command:
get-process

Find java-se process id, then type command:


taskkill /pid 15760 /F
Now you can try debugging again with NetBeans and tomcat.
6. Working with JSTL.
Latest version of JSTL build on J2EE was 1.2x. Since the Tomcat 10 is using Jakartified version
(with jakarta.* package instead of javax.* package), use JSTL 2.0 to solve this dependency:
Download: Jakarta Standard Tag Library API
Link: https://search.maven.org/artifact/jakarta.servlet.jsp.jstl/jakarta.servlet.jsp.jstl-api/2.0.0/jar

Download: Jakarta Standard Tag Library Implementation


Link: https://search.maven.org/artifact/org.glassfish.web/jakarta.servlet.jsp.jstl/2.0.0/jar

Check the document here:


https://jakarta.ee/specifications/tags/2.0/jakarta-tags-spec-2.0.html
7. Working with JDBC.

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:

You might also like