KodeCloud Applications
Links: 111 KodeCloud Index
Java¶
-
Upgrade from version 8 to version 9 was not backward compatible and resulted in a lot of broken packages hence you will see a lot of companies still using Java 8.
-
Java 8 version number is
1.8
. This changed with version 9.
What is a JDK?
- JDK is a set of development tools which will help us develop, build and run the java application.
- These tools are present in the
bin
directory of the jdk
jdb
is used for debugging java applications andjavac
is used for compiling java code.
-
JRE (Java Runtime Environment) is used to run the Java applications on any system.
- JRE and the
java
command line utility are the only components required to run already built Java applications on a system.
- JRE and the
-
Before version 9 of Java JDK and JRE were shipped as separate components.
- So if you were not developing a Java application and just wanted to run them then you could have only downloaded the JRE.
- After version 9 JRE is packed into JDK.
- JVM
Building & Packaging¶
- JAR stands for Java Archive it helps compress and combine multiple Java class files and its dependencies into a single distributable package.
jar cf JarFileName.jar file1 file2 ....
- Incase of a web application we have static files like html and css. They are packaged in a WAR (Web Archive) file.
-
When
jar
command is run it automatically generates a manifest file within the package at pathMETA-INF/MANIFEST.MF
- This file contains information about the files packaged in jar file and any other meta data about the application
- One important information present in the meta data is the entry point to the application.
-
Once jar is built it can be run on any platform using
java -jar JarFileName.jar
-
Generating documentation for the code:
javadoc -d doc MyClass.java
-
When working with large software it can get really cumbersome to package and generate documentation for the project.
- This is where build tools like Maven, ANT and gradle are used.
-
ANT example:
- If we want to run specific sections of ANT then we can use
ant compile jar
NPM (JavaScript)¶
- When you install a npm package they are installed inside the
node_modules
folder in the current directory. - A directory by the name of the package is created it contains different files like
README.md
,LICENSE
,package.json
and thelib
folder contains the code. - The
package.json
inside the package is the file which contains meta data for the package like its name, version, author, its git repository.- This file is useful when you are troubleshooting issues related to dependency.
When we import a package node first looks for the package in the local node_modules
directory if the package is not found then it looks in other locations.
We can find the look up order by priority using the following command.
- We can install the package globally using:
npm -g install <package-name>
- There are two types of modules:
- BuiltIn: These are installed automatically when nodejs is installed for the first time.
- External
Python¶
- Python versions:
- Python2: 2000 - 2010
- Python3: 2008 - Till Date.
- When we install Python PIP gets installed automatically.
- If we have multiple python versions then we will have different pips.
So if you don't know to which python pip is pointing just use pip -V
- When Python is installed it creates the following package structure.
- A directory is created for each version of Python under the
/usr/lib
directory.
- A directory is created for each version of Python under the
- When we install a python package using pip it places it in the
site-packages
folder in the appropriate python folder.- This may not be completely true as they can also be installed in different locations.
- Packages can also be 32 bit or 64 bit so a separate path is available.
Finding the location of a particular package
pip show <package-name>
-
When importing a package python looks at a list of paths to find and import the package.
- We can list the paths using
print(sys.path)
- We can list the paths using
-
To install a lot of packages we use
requirements.txt
pip install -r requirements.txt
- It is a best practice to specify the version of packages in
requirements.txt
file.- If no version is specified then python will install the latest version of the package.
- Upgrading a package:
pip install <package-name> --upgrade
- Uninstalling a package:
pip uninstall <package-name>
-
Other package managers:
- Eggs don't need to be unpacked but they are obsolete
- Wheels are similar to eggs but they need to be unpacked.
-
To install a wheel package we do
pip install package.whl
Last updated: 2022-09-16