Welcome to Codefind4you !

Follow Me

How to Install JDK on OpenSUSE Leap 42.1 x86_64.


This tutorial will cover the installation of 64-bit JDK 8u112 on OpenSUSE

  1. Update OS
     zypper update
  2. Checking the current java version and remove OpenJDK (if you want)
     java -version

     zypper remove *OpenJDK*
  3. Checking the java version again(if you want to confirm whether OpenJDK
    is removed
    )
  4. Make a directory “java” in /usr/local/
     cd /usr/local/

     mkdir java
  5. 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"

  6. 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
     


  7. Create “latest” directory and create link as shown below
     ln -s jdk1.8.0_112 latest


  8. 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

  9. Reload the “.bashrc file .
     source ~/.bashrc
  10. Edit “bash_profile” file and insert the code as shown below
    vi ~.bash_profile

    if [ -f ~/.bashrc ]; then
                    source ~/.bashrc
    fi
  11. Checking the java version and javac working.

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).

Let us see the below example



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.  





Contact Form

Name

Email *

Message *

Translate