How to build a JAVA Project. What is JAR? And How to create a JAR file?
What is Version? Maven is a Powerful Build Management. Maven Architecture and Maven Environment Setup. Maven POM.xml and Build Life Cycle. How Maven Repository is utilized.
2. Building a Project
❖ Creating a Executable file from the Project files
HelloWorld.java Java Compiler HelloWorld.class
Java Project Java Compiler HelloWorld.jar
3. Java Archive (JAR)
❖ JAR file is a compressed version of Class files
❖ JAR is a Package file contains
➢ Many JAVA Class Files (which is executable by JVM)
➢ Supporting configuration files (property files and other format data files)
➢ Resources such as text, image etc
➢ External Library files
5. Version
● Each Software is subject to change or update its features
For example,
Initially a site can have signup with manual form. Then after a while, signup via
google credentials is created. Then after a while, signup via other social media
such as Facebook or linkedin will be created
● This changes in a software code is tracked as version
6. Selenium, Driver other Versions
❖ Selenium WebDriver is about to release Version 4 and is on beta testing
❖ Version history of WebDriver Link
❖ Browser versions are upgrading always to meet security and features
❖ This changes driver versions
❖ Chrome version history Link
7. Maven
❖ Powerful Project Management Tool for building a project
❖ Manage projects in various languages such as C#, Ruby and Scala, etc.
❖ Managing different dependencies with ease
8. Maven Project Structure
src/main/java directory includes the java source code
deliverables
src/test/java directory includes the Testing source code
in which our code will be present
resources directory includes the property files, images
and other useful resources for this project
target directory is the default output folder when the
project is build or packaged
9. Maven Environment Setup
❖ Maven is a Java Based tool and Requires JDK environment to setup
❖ Verify Java installation is present in the machine
Java -version
❖ Download maven Archive link from https://maven.apache.org/download.cgi
❖ Extract the archive folder
❖ Set Maven Environment Variables in windows
M2_HOME = C:Program Filesapache-maven-3.3.1
MAVEN_HOME = C:Program Filesapache-maven-3.3.1
MAVEN_OPTS = -Xms256m -Xmx512m
10. Maven Environment Setup
❖ Add System variables in windows
❖ Add Bin to System variable path
C:Program Filesapache-maven-3.3.1bin
❖ Verify Maven is installed
mvn -version
11. POM.xml
❖ Project Object Model is the core of maven
❖ It contains details to build the project
➢ Configurations
➢ Dependencies
➢ Plugins and Goals
➢ Build Profiles etc.
❖ Also contains information of project version, description, developers and
mailing lists, etc.
12. Initial POM
❖ Group Id : Generally it is a process or department name in which Project is used
❖ Artifact Id : Project name
❖ Version : Project Version
13. Maven Build Life Cycles
❖ Build Life Cycle in Maven is a predefined set of execution instruction
❖ Any Build Life cycle majorly contains the following Instruction / phases in any
order
compile Source Code is compiled using the compiler. (e.g. javac)
prepare-resources Customizing the resources to copy
package JAR/WAR package creation as mentioned in POM.xml
install Installs the package in a repository
deploy copies the final package file to a desired location
14. Some Maven Commands
mvn clean
❖ It will delete the build directory. Target folder is the place all class files are
stored
mvn install
❖ Will pack the resources
❖ Will compile the java files
❖ Will pack the files to jar in maven directory
15. Maven Repository
● Local Repository
In our local system
● Remote Repository
A shared space
● Central Repository -
https://mvnrepository.com/