DEV Community

Shahriyar Al Mustakim Mitul
Shahriyar Al Mustakim Mitul

Posted on • Updated on

DevOps Prerequisite (Part 3): Application basics (NodeJs & Python)

I general we have compiled and interpreted languages

Image description

For compiled codes, it's first developed, then compiled and then run. They don't work in different system.

Image description

For interpreted ones, it is developed and then run

Image description

But it does compile into bytecode and run in the process "run" . We don't have extra compiler stage rather it is done in the "run" step.

This is how a python code gets executed

Image description

we write a code which is compiled to a bytecode and then the interpreter translate that to machine code which the computer understand.

With the use of Python VM, we can compile our byte codes very easily

Image description

Java
This is how we can install java in our linux based systems

Image description

Now we can see a word "jdk". What's that?

JDK is a tool which consists of all tools required to develop , build and run the codes of java

Image description

For example, to develop java codes, jdb, javadoc etc are used.

You can see the list of tools installed within jdk directory

Image description

It's kept in the /bin file though

Lab

Let's install Java 20 inside /opt folder
sudo curl https://download.java.net/java/GA/jdk20/bdc68b4b9cbc4ebcb30745c85038d91d/36/GPL/openjdk-20_linux-x64_bin.tar.gz --output /opt/openjdk-20_linux-x64_bin.tar.gz

sudo used for administrative access, curl for the download and the original download link is "https://download.............." and then we saved the result to /opt folder in the name of "openjdk-20_linux-64_bin.tar.gz"

Image description

So, we installed the compressed file (.gz)

Now, let's uncompress

sudo tar -xf /opt/openjdk-20_linux-x64_bin.tar.gz -C /opt/
tar is used to decompress and used the folder location /opt/opejdk_... and saved the files in /opt folder

Image description

Once done, we can check these files available in the folder

Image description

Now, it's installed as it's decompressed. We can check the version by going into the jdk-20 folder's bin folder

Image description

How to build in Java?

This is how a typical compiling file (MyClass.class) might look

Image description

But a typical file might have dependencies and other class files to compile

Image description

Which we can compress using a jar command.

Image description
Here jar cf is followed by jar file name and all class files and dependencies we need to compress

The informationabout the jar file is saved in META-INF folder

Image description

Using the javadoc we can then document our java file so that others can read that

Image description

SO, as a whole we can manually compile , package and document our MyClass file

Image description

But there are tools for java (Maven, Gradle, ANT) which can do these process for us

Image description

For example, using the ANT we can provide the compiliting (javac), documentation (javadoc), package (jar) them

Image description

here you can see for compiling we have
<javac srcdir='/app/src" destdir='/app/build"
Here srcdir is the source folder where our code is and we have to compile that to /app/build folder

Image description

For documentation,

Image description

For packaging using jar,

Image description

For Maven, it's almost the same

Image description

And for Gradle,

Image description

NodeJs
Earlier we had this as a website using HTML and CSS:

Image description
But now we have this one:

Image description
JavaScript (Js) made this difference.

Here NodeJs is server site JavaScript environment

Image description
This is how we can install nodeJs in centos:

Image description

Image description

NPM (Node Package Manager)

Image description

So, nodejs and npm is not same but npm manages nodes .

Image description

Image description

Image description

Image description
Modules
Image description

Python

Versions:

Image description
This is how this code works:
Image description

PIP (Python package manager)

Installing something using pip does this:

Image description
Here we have 2 python versions enabled here and we found out that currently pip is enabled on version 2.
So, if we install this flask package, we will create this file under this.

Image description

Image description
Checking paths :
Image description

Importing python packages in to codes:

Image description
Run required all files using a txt file or manually.

Image description

You can manually installed dedicated versions too.

Image description

You can also upgrade and delete them.

Image description

Moreover, these are other ways to run python (.py) files.

Image description

Top comments (0)