How to Install JDK on OpenSUSE Leap 42.1 x86_64.
This tutorial will cover the installation of 64-bit JDK 8u112 on OpenSUSE
- Update OS
zypper update
- Checking
the current java version and remove OpenJDK (if you want)
java
-version
zypper remove *OpenJDK*
- Checking the java version again(if you want to confirm whether OpenJDK
is removed)
- Make
a directory “java” in /usr/local/
cd /usr/local/
mkdir java
- Move
to “java” directory and Download “jdk-8u112-linux-x64.tar.gz”
file
into the /usr/local/java directory as shown below.
cd
java
wget
--no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F;
oraclelicense=accept-securebackup- cookie"
"http://download.oracle.com/otn- pub/java/jdk/8u112-b15/jdk-8u112-linux- x64.tar.gz"
- Once
file has been downloaded, you may extract the tarball using the tar command and delete tar file as shown below.
tar
-zxvf jdk-8u112-linux-x64.tar.gz
rm
-rf jdk-8u112-linux-x64.tar.gz
- Create
“latest” directory and create link as shown below
ln
-s jdk1.8.0_112 latest
- Edit
“bashrc” file and insert the code as shown below
vim
~/.bashrc
export JAVA_HOME=/usr/local/java/latest
export PATH=$JAVA_HOME/bin:$PATH
- Reload
the “.bashrc file .
source
~/.bashrc
- Edit
“bash_profile” file and insert the code as shown below
vi
~.bash_profile
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
- Checking
the java version and javac working.
zypper update
java -version
zypper remove *OpenJDK*
is removed)
cd /usr/local/
mkdir java
into the /usr/local/java directory as shown below.
cd java
wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F;
oraclelicense=accept-securebackup- cookie" "http://download.oracle.com/otn- pub/java/jdk/8u112-b15/jdk-8u112-linux- x64.tar.gz"
tar -zxvf jdk-8u112-linux-x64.tar.gz
rm -rf jdk-8u112-linux-x64.tar.gz
ln -s jdk1.8.0_112 latest
vim ~/.bashrc
export JAVA_HOME=/usr/local/java/latest
source ~/.bashrc
vi ~.bash_profile
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
fi
Different between Interpreter, Compiler ,JIT and How
Java works.
Executing Programs
- Computer can only execute the code in binary form.
- A program written in a high –level language is called a source program or source code.
- Because a computer cannot understand a source program, a source program must be translate into machine code for execution.
Source code – Written in high-level
language
Machine code –Computer processor can
understand
- The translation can be done using another programming tool called an Interpreter or Compiler (So this interpreter and compiler are normally used to translate the code from one form to another form )
What is Compiler
A compiler is a program. It translates
the entire source code into a machine code file or any intermediate code and
that file is then executed.
What is Interpreter
An interpreter is a program. It reads one statement from the
source code, translates it to the machine code or virtual machine code and the
executes it right away.
How Java Works
In case of Java, compiler will
convert the source code (.java file) to an intermediate
code (byte-code / .class file) that the java virtual Machine can
understand (JVM /Interpreter).The
JVM convert intermediate code (byte-code / .class file) into machine
code.
(In the
java, javac is used to convert source code to intermediate code. javac-java
compiler).
Just In Time Compiler (JIT)
Above you can see that we have 6 statements which 3 of them
are redundant. Compiler (javac) compile the source code to byte-code. Now, when
we run the program, the interpreter translate line by line.
The compile code, intermediate code, byte-code or .class file
will go through the JIT compiler and optimize code. In this case, line 4, 5, 6
are redundant and JIT compiler will not this code as redundant. So when the
file gets the interpreter, the interpreter will now know the code in line
number 4 is going to come again.so, it’s store machine code of line number 4 somewhere
in computer memory and when it comes the same piece of code again, it is simply
tells the computer to run machine code directly without translating .This phenomenon is called JIT compilation and this significantly
improve performers.
JVM-This is platforms dependent. So, Windows, mac, Linux,
etc… platforms specific JVM’s are capable of executing that same java byte-code
in the same way.