I general we have compiled and interpreted languages
For compiled codes, it's first developed, then compiled and then run. They don't work in different system.
For interpreted ones, it is developed and then run
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
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
Java
This is how we can install java in our linux based systems
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
For example, to develop java codes, jdb, javadoc etc are used.
You can see the list of tools installed within jdk directory
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"
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
Once done, we can check these files available in the folder
Now, it's installed as it's decompressed. We can check the version by going into the jdk-20 folder's bin folder
How to build in Java?
This is how a typical compiling file (MyClass.class) might look
But a typical file might have dependencies and other class files to compile
Which we can compress using a jar command.
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
Using the javadoc we can then document our java file so that others can read that
SO, as a whole we can manually compile , package and document our MyClass file
But there are tools for java (Maven, Gradle, ANT) which can do these process for us
For example, using the ANT we can provide the compiliting (javac), documentation (javadoc), package (jar) them
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
For documentation,
For packaging using jar,
For Maven, it's almost the same
And for Gradle,
NodeJs
Earlier we had this as a website using HTML and CSS:
JavaScript (Js) made this difference.
Here NodeJs is server site JavaScript environment
This is how we can install nodeJs in centos:
NPM (Node Package Manager)
So, nodejs and npm is not same but npm manages nodes .
Python
Versions:
PIP (Python package manager)
Installing something using pip does this:
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.
Importing python packages in to codes:
Run required all files using a txt file or manually.
You can manually installed dedicated versions too.
You can also upgrade and delete them.
Moreover, these are other ways to run python (.py) files.
Top comments (0)