Sitemap
Ashmeet Kaur

Ashmeet Kaur

Writing articles on core Java Development .

Software Developement

3 min readAug 31, 2023

Phases of Software Development
⇥Developement →firstly the dev needs to be done
⇥SCM->The developers push their code to repo.
⇥Build->The code get compiled here . as in the .java get converted to .class.
⇥Publish->.class files are saved at certain places.Stores all the files
⇥Test->These test cases are unit test cases which are test by developer.
⇥Deploy->if all the unit test are working fine ,then we will be deploying our project in the server.
⇥Enviroment->whenever we deploy our project, we can deploy it in any enviromnent ,like dev,testing,production.

Standard multi-file java project structure for java project
▪︎ src/main/java-
The whole code should be there.(source code of the project)
▪︎ src/main/resources-
Here all the configurations should be there.
▪︎ src/test/java-Contains the test cases.
▪︎ src/test/resources-
All the configuration related to the test cases are there .
▪︎ bin- Contains the .class files in the bin folder.
▪︎ lib- contains all third party projects.

Java ClassPath
A list of directories ,JAR files and zip archives to search for class files .
JVM uses java classPath to find classes during runtime.
When building and running a java project two classpaths are involved
a).Compile ClassPath-List of dependencies that are required for the jdk to compile java code into .class file.
b).RunTime ClassPath-List of dependies required to run the compiled java code.

How to build a jar file ?
Compile the java project
Command Line Execution
javac -d bin -cp <classpath indicating files and library to include> <list of java classes>
-d means which directory to generate compiled classes
-cp specifies the list of directories,jar archives and Zip archives to search for class file.
Compile
javac -d bin -cp @classpath.txt @mainsources.txt
Run the application
java -cp @classpath.txt com.crio.session5.activity1.WeatherAdvisorApplication 12.916277.6033 “2020–05–29 08:15” “2020–05–29 09:15” v2
While we are running the application, we have tp mention Runtime classpath.

Testing of Project
Unit test all the testcases in the java project.
Command line execution
java -jar <path of junit-platform-console-standalone.jar> -cp <Class path indicating files/classes/libraries to include> — scan-class-path.

— scan means it telling that please scan the whole test cases.

Jar
A jar(java archive) is a package file format.It clubs all the file and stores it in a single package or jar file.

Get Ashmeet Kaur’s stories in your inbox

Join Medium for free to get updates from this writer.

Command line Execution
jar cvfm <jarname.jar><path to manifest file> -C <path to directory containing classes>
jar cvfm WeatherAdvisorApplication.jar ./jar_manifest.txt -C ./bin/.

Run the jar file
java -jar ./WeatherAdvisorApplication.jar 12.916277.6033 “2020–05–29 08:15” “2020–05–29 09:15” v2

All above are very tedious process . can we automate this ?So, all the organisations mostly uses the build tools to automate this tedious process. we no need to download every single file or create compile classpath or runtime classpath. and remember these above bigger statements . So for this reason build tools has been designed .

So what is a build tool ?
Build tool is a program that helps in compiling ,testing,packaging, and deploying of source code in the most efficient manner.
Advantage:
a).Automate menial work.
b).Manage Depeendencies
c).Execution of task in correct order
d).Continuous Integration and Deployment.

Popular Java Build Tools
a)Ant
b)Maven
c)Gradle

Gradle Build Tools Approach
a)./gradlew build - for Compilation
b)./gradlew test -for testing
c)./gradlew run- for running jar
d)/gradlew jar-for creating package

--

--

Ashmeet Kaur
Ashmeet Kaur

Written by Ashmeet Kaur

Writing articles on core Java Development .