DEV Community

Shahriyar Al Mustakim Mitul
Shahriyar Al Mustakim Mitul

Posted on

DevOps Prerequisite (Part 3): Application basics and Java

Programming language can be classified as Compiled and interpreted.

Image description

1.Compiled (Developed-> Compiled -> Executed): C, C++, Java. Compiled program is first written and then it is compiled for a machine . It works for the specific machine it is designed for.

Image description
For java, it it:

and

  1. Interpreted (Developed ->Executed): Node.js, ruby, python. Here the program is developed and then it runs. The basic code is generally encrypted as a bytecode and then it runs.

Image description

Basics:

In old days, for Python
This is what compiler used to do:

Image description
It would create a machine code which is different for different languages.

Nowadays,
But to solve this issue, there came bytecode .

Image description
This bytecode is then interpreted by the python interpreter

The bytecode is then converted into a machine language by the python virtual machine (an environment to run python)

Image description
So, as long as the environment exists, it creates a machine language from source code . The machine language is implemented and the code runs.

So, running main.py does all of these in background.

Image description

For Java,

Image description
you can develop your code once and compile it and then run it everywhere. This makes java cross platform.

Image description

Basics of Java
It is a free and open sourced community

Image description
Install java on CenTos:

Image description
Let's check a situation:

Image description
Here what happened is :

ssh app01 to login to app01 server and run below command to download
sudo curl https://download.java.net/java/GA/jdk13.0.2/d4173c853231432d94f001e99d882ca7/8/GPL/openjdk-13.0.2_linux-x64_bin.tar.gz --output /opt/openjdk-13.0.2_linux-x64_bin.tar.gz

To uncompress run sudo tar -xf /opt/openjdk-13.0.2_linux-x64_bin.tar.gz -C /opt/

To verify run /opt/jdk-13.0.2/bin/java -version on app01 and confirm correct version is installed.

This is how we are going to install java in this situation.

Image description

Image description

Done with installing!!!

Here you will need jdk which is actually installed while installing java:

Image description

This is what develops, builds and runs your code.

before the version 9 of java, JDK & JRE had to be installed differently. They were not in one single package.

Image description

But after that JRE is within the JDK

Image description

More about java
Java is compiled like this:

Image description
Java code is compiled to a bytecode and then run in a Virtual Machine.

This is how java code is packaged:

Image description
using the jar command , we create a output file named Myapp.jar using the contents MyClass.class,Service1.class..........

Image description

When this file is created it automatically generates a manifest file within the package at path "META-INF/MANIFEST.MF"

Image description

The contains information about the package details.

Once built and compile , java code can be run any where.

Image description

For documentation, we use javadoc
It is basically shown in a html version after documentated.
Image description

So, in the build process the code is developed, compiled, packaged and documented.

Image description

For the complex codes, this can become messy and thus there are some build tools which can be used for Java:

Image description
You can specify the build rules or the order to proceed for the build tools:

Image description

For example, lets use a build tool ANT:
Generally or manually we would develop, document and package the code:

Image description

But using build tool,
This is how we will use XML format :
To develop
Image description
To document

Image description
To package

Image description

Then we run the command

Image description

For other build tools like Maven,

Image description

Image description

Image description

That was it for this blog, check the other part from here

Top comments (0)