How to start writing your first Webapp
Hello! everyone, this is my first story in the web application series. Before writing, you have to set up the environment for your life changing projects. As we all know, Java is everywhere, I decided that all of the story in this series we will use Java Standard Edition 14 as the main tool for developing our web app. So first, install Java. For the safety of your computer, I suggested that you should Sign Up for Oracle account so you can get the latest version of Java.
Here this is the link : https://www.oracle.com/java/technologies/javase/jdk14-archive-downloads.html
For Windows
You can download either the Installer or the Compressed Archive.
If you download the Compress Archive, make sure you Extract it to the Program Files folder.
For macOS
You should use the Installer.
To check you success, use this command in the terminal :
java -version
For Ubuntu
you can use this command in the shell :
sudo apt install openjdk-14-jdk
or :
sudo apt install default-jdk
(older than the 14th version is still good)
The second key environment for the development is NetBeans IDE.
In this series we will use NetBeans 12.1
You should use the Binary Zip file (bin.zip) and Extract it to the same folder with Java (where you extract Java). But in Windows, I suggested the installer.
The last one is Tomcat web server, I suggested tomcat 9.0.39
Here this is the link: http://tomcat.apache.org/download-90.cgi
scroll down to 9.0.39 and download to Core: zip file in Binary Distribution.
Extract it, change the extract folder name to “tomcat” and remember where it was.
There is few additional command you have to execute in the shell, if you use Unix operating system.
Here it is :
chmod +x ~/WhereTomcatWas/tomcat/bin/*.sh
chmod +x ~/WhereTomcatWas/tomcat/bin/startup.sh
chmod +x ~/WhereTomcatWas/tomcat/bin/shutdown.sh
Come back to NetBeans, go into NetBeans-12.1,go into netbeans, and go into bin folder. You will find :
“netbeans” is for Unix and “netbeans64.exe” is for Windows.
After you clicked it, It will start NetBeans 12.1 for you.
In NetBeans, press CTRL+5. The Services window will appear.
Right click on Servers then click Add Server…
Select “Apache Tomcat or TomEE” and give your server a name, then click Next.
Browse the Server Location to the folder you renamed to tomcat. Set the Username and Password then click Finish.
Back to Servers, inside, your server will be found. Right click at the server name, then click Start to start the server.
Press CTRL+Shift+N to create New Project.
Select Java with Maven, select Web Application then click Next.
Name the project, Artifact Id, Group Id and Version, then click Next.
Select your Tomcat server, then Finish.
Now, go to Files window click on your Project name then double click on pom.xml to edit it.
Replace “7.0” in <version></version> with “8.0.1” or “RELEASE”.
Now Build and Clean with the hammer and broom button, then run the project with the green arrow button.
Then, This will be founded :
Now your environment is ready.
It would be very interesting if you try adding html template into this project.
Here this is the link : https://www.free-css.com/free-css-templates
Download the template, Extract it, go deep into that folder and find the file name “index.html”
Bring all files that was in the same folder as index.html to \Documents\NetBeansProjects\Dev\src\main\webapp (replace old index.html file with the new one)
Build and clean the Run.
Here this is example of the success :
Hurray! this is the first step of your success but it still only in localhost. Next time I will show you how to make your project accessible by others with Google Cloud.
See you.