Download as pdf or txt
Download as pdf or txt
You are on page 1of 18

ENVIRONMENT SETUP – JAVA SPRING

1) Ubuntu 22.04
2) JDK 17
3) Apache Tomcat 10.1.12
4) NetBeans 18
5) MySQL 8.0.34 + Workbench

1) Ubuntu 22.04
NOTE: If you already have Ubuntu installed, then if you have 22.04
instaleld you can skip this step. For eariler versions of Ubuntu, please
go to this page: Upgrade Ubuntu desktop | Ubuntu

First of all download the ISO file on this link:


https://releases.ubuntu.com/jammy/ubuntu-22.04.3-desktop-
amd64.iso
For this guide, we will show you how to install the OS on a VM
platform only. If you are interested in Dual Boot installation, please
refer to this guide: Install Ubuntu 22.04 Jammy alongside Windows 10
(Dual Boot) (how2shout.com)

First, install VMWare Player via this link: VMware Workstation Player -
VMware Customer Connect
Choose “Download Now” for WIndows 64-bit
Open the downloaded .exe file, then install the program. After you
finished installation, open the program, it should look like this

After that, create a new VM by clicking Create a New Virutal Machine,


it should show this window
Select Installer disc image file and browser the location of your downloaded
Ubuntu ISO
Then, type in your user information
After typed in the user information, specify your VM name and the folder where
you want to store the VM
After that, specify the amount of storage you want for the VM. I would
recommend way higher than 20 GB though. Make it 60 GB.
Finally, check if there are any specs you want to change for the VM, then click
finish to end the wizard (and power on the machine if you left the checkbox
ticked)
For anyone curious, this is the screen after you press “Customize
Hardware..”
Then proceed to power on the newly created VM then follow the instructions.
Refer to this Install Ubuntu desktop | Ubuntu for more.
After finished install, you should see the screen is not optimized for full screen.
You should first install vm tools by going to the terminal, then type:
sudo apt-get update
sudo apt-get install open-vm-tools-desktop
sudo apt-get install open-vm-tools
After all are done, proceed to restart the VM. After your VM boots up,
you should see the desktop covers the VM screen fully.
0) Download snap (This is tool for us to download apps)
- Run terminal :
sudo apt update
sudo apt install snap
If you already have snap in your vm then you can skip this part

2) JDK 17
Open the Terminal, then type
sudo apt install openjdk-17-jdk
Provide the password if you are required to
Type y and press enter to proceed installation

3) Apache Tomcat 10.1.12


- Create Tomcat user and group by terminal
sudo groupadd tomcat
sudo useradd -s /bin/false -g tomcat -d /opt/tomcat
tomcat

- Then, change to the /tmp directory with the command:


cd /tmp
- Now, use the curl command with the tar.gz link you copied in step 2
to download the package:
curl -O https://dlcdn.apache.org/tomcat/tomcat-
10/v10.1.12/bin/apache-tomcat-10.1.12.tar.gz
- To extract the tar.gz Tomcat file, create a new /opt/tomcat/
directory with the command:
sudo mkdir /opt/tomcat
- Then, extract the file in the new directory with the following
command:
sudo tar xzvf apache-tomcat-10*tar.gz -C /opt/tomcat --
strip-components=1
- Move to the directory where the Tomcat installation is located:
cd /opt/tomcat
- Grant group and user ownership over the installation directory to the
tomcat group and user with the command:
sudo chown -RH tomcat: /opt/tomcat
- Lastly, change script permissions to grant execute access in
/opt/tomcat/bin/with:
sudo sh -c 'chmod +x /opt/tomcat/bin/*.sh'
- Create and open a new file in the /etc/system/system under the
name tomcat.service:
sudo nano /etc/systemd/system/tomcat.service
- Once the file opens, copy and paste the content below, changing
the JAVA_HOME value to the information you found in
the previous step.
[Unit]
Description=Apache Tomcat Web Application Container
After=network.target
[Service]
Type=forking
User=tomcat
Group=tomcat
Environment="JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64"
Environment="JAVA_OPTS=-Djava.security.egd=file:///dev/urandom -
Djava.awt.headless=true"
Environment="CATALINA_BASE=/opt/tomcat"
Environment="CATALINA_HOME=/opt/tomcat"
Environment="CATALINA_PID=/opt/tomcat/temp/tomcat.pid"
Environment="CATALINA_OPTS=-Xms512M -Xmx1024M -server -
XX:+UseParallelGC"
ExecStart=/opt/tomcat/bin/startup.sh
ExecStop=/opt/tomcat/bin/shutdown.sh
[Install]
WantedBy=multi-user.target
- Save and Exit the file (Ctrl+X, followed by y[es] and Enter).
- For the changes to take place, reload the system daemon with the
command:
sudo systemctl daemon-reload
- Now, you can finally start the Tomcat service:
sudo systemctl start tomcat
- Verify the Apache Tomcat service is running with the command:
sudo systemctl status tomcat

- Open Port 8080 to allow traffic through it with the command:


sudo ufw allow 8080/tcp
- If the port is open, you should be able to see the Apache Tomcat
splash page. Open Chrome or Edge and url like localhost:8080

4) Netbeans
- install netbeans
sudo snap install netbeans –classic
- Add tomcat to netbeans:
Tools => Server => Add Server => Apache Tomcat or TomEE =>
Browser => /otp/tomcat => Open
Open => Create User => Finish

NOTE: There is a case that you could encounter this error:

The reason for this error is because the IDE hasn’t got any
permission to access that folder. To able to fix it, you should own the
folder by use terminal:
sudo chmod 777 –R /opt/tomcat
Or:
sudo chown your_vm_username –R /opt/tomcat
After you have done everything, browse to that folder again and
you should see no more errors, but the notice to provide username and
password.
Fill in username and password and finish

5) MySQL
- Download mysql server: Run terminal
sudo apt update
sudo apt-get install mysql-server
- Set up user for mysql
sudo mysql –u root –p
Just <Enter> because password is blank, then you go to mysql
ALTER USER 'root'@'localhost' IDENTIFIED WITH
mysql_native_password BY 'your_new_password';

Replace your_new_password by your password

Then exit
- Download mysql workbench: Run terminal
sudo snap install mysql-workbench-community

You should see the MySQL Workbench app icon when you search
for it in the menu:

You might also like