Hello Everyone In this tutorial you will learn. The complete configuration of the java project. Please follow the following steps one by one.
Install Java Development Kit (JDK)
At the very first step, you need to be Installed JDK on your machine. So before installing please check JDK on your machine if it’s not there then you need to download and install the new current JDK available in the market. But as per the codebun’s project, JDK 1.8 will be enough.
Download JDK 1.8 from the below link
>Download JDK
Install JDK 1.8
Click on the downloaded JDK file and Install it like window software or follow the step from the video.
Check the Installation for confirmation
Follow the path “C:\Program Files\Java” and check the JDK with the version.
IDE configuration
Step 1: Download the STS tool from the
>>Download STS link 3.9
Step 2: Extract the Zip file
Step 3: Follow the path “sts-bundle\sts-3.9.1.RELEASE”
Step 3: Run the sts application.
Video tutorial to install STS tool
Import Project in your IDE
Step 1) Run your sts tool or Eclipse.
Step 2) Click to file at the top left corner and click to import.
Step 3) Select Maven> Existing Maven Project and click on the Next button.
Step 4) Browser your project from the location and click next then finish and wait until the import process is finished.
Step 5) Right-click on the project and select properties from the bottom.
Step 6) Select “Java build path” Then “Libraries”
- Edit “JRE System Library” and select “Execution Environment” as 1.8 and click to finish.
- Click on “Order and Export” Check the “JRE System Library” checkbox and click to apply.
Step 7) Select “Project Facets” from the properties and change the java version to 1.8 and click to apply and finish.
Database Configuration
We are using MYSQL as the back-end for every project with the MYSQL workbench.
Step 1) Download Complete MYSQL setup
>>Download Complete MYSQL
Step 2) Install MYSQL to check the steps please follow the video linked below >>Link
Step 3) Run MYSQL Workbench.
Import Database in MYSQL workbench.
Step 1) open the workbench and connect with the MySQL server.
Step 2) Click on “server” and select “Data Import”.
Step 3) Select the option “Import from self-Contained file” browse the file from the location and click to import button.
Step 4) Refresh your database server.
Step 5) Finally you will get your database:)
I will suggest you to keep the database connection name = “root” and password = “root”. Because we are using the same in every project.
Server configuration
To deploy our java project we are using Tomcat 8.5.
Step 1) Download tomcat 8.5
>>Download Tomcat 8.5 Link
Step 2) Extract the File and copy it at any location in your machine for example “C drive”.
Step 3) Again Switch to sts tool/Eclipse and search for server window. Follow the path to find the server window
=>Windows=>Show view=>Others=> Server.
Step 4) Right click in the server window and select
New=>server=>Apache=>Tomcat 8.5 Server=>Next.
Step 5) Browse the tomcat folder which we had copied in “C drive”.
Step 6) Click to Next and Finish.
Finally, Run Your Project
Step 1) switch to STS tool/Eclipse.
Step 2) Right-click on the project and select “Run As” then “Run on server”.
Step 3) Select “Tomcat 8.5” from the localhost.
Step 4) Click next and finish.
=Not==TATA==BY-BY==Finish=
So Till now, we have covered the complete process of java web project configuration. In the below steps, we will cover the error which you may find during the configuration process. I have covered most of them but If you get any new error during the configuration. please comment to me with the screenshot. We will find the best solution and link here to the solution.
Solve Errors
Port 8080 is already in use.
Solution:
Step 1) Switch to the STS/Eclipse tool server window.
Step 2) Double-click on “Tomcat server 8.5” and observe the post section table.
Step 3) Change the port number from the “Port Number” column and Save (ctrl+s).
Step 4) Clean and restart the server.
How to change the table data in MYSQL || Explore the database
Change the database password in the project || Edit system.properties file
All the projects are using the default password “root” for the database. So Might be it possible you have some other password for your database so before running the project you have to change the database password in System.properties file. Please check this video to open the system.properties and change the password.
Change the Image or File Path || FileNotFound Exception
If you are using any project where you need to manage Images or files. Like any eCommerce project then you have to change the file or image path. Please follow the steps shown in the below video to solve the error.
Update MYSQL version 8.0 in Java project
We are using MYSQ 5.6 in all the projects but if you are using the latest versions of MySQL. Like MYSQL 8.0 So you have to make some changes in the Java project as well. Please follow the below video to make the changes accordingly.
More Helpful articles for Java Project configuration
- Getting error in MYSQL
- Download .m2 directory
- Only for the Spring Boot Import the Lombok plugin into Eclipse or STS IDE.
- Lombok configuration URL: https://projectlombok.org/p2
Verify Database connection manually
public static void main(String[] args) { try { Class.forName("com.mysql.cj.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/tourandtravel", "root", "root"); System.out.println("Con: "+con); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
Verify required plugins into pom.xml
<pluginManagement> <!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) --> <plugins> <plugin> <artifactId>maven-clean-plugin</artifactId> <version>3.1.0</version> </plugin> <!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging --> <plugin> <artifactId>maven-resources-plugin</artifactId> <version>3.0.2</version> </plugin> <plugin> <artifactId>maven-compiler-plugin</artifactId> <version>3.8.0</version> </plugin> <plugin> <artifactId>maven-surefire-plugin</artifactId> <version>2.22.1</version> </plugin> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.2.2</version> </plugin> <plugin> <artifactId>maven-install-plugin</artifactId> <version>2.5.2</version> </plugin> <plugin> <artifactId>maven-deploy-plugin</artifactId> <version>2.8.2</version> </plugin> </plugins> </pluginManagement>
Spring DB Connection configuration
spring.datasource.url=jdbc:mysql://localhost:3306/searchmedicine?createDatabaseIfNotExist=true spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.username=root spring.datasource.password=6264 spring.jpa.properties.hibernate.dialect= org.hibernate.dialect.MySQL8Dialect spring.jpa.generate-ddl=true spring.jpa.hibernate.ddl-auto=update server.servlet.context-path=/api server.port=9091
Step-by-step Java web application development tutorial.