DEV Community

Pavithra Saravanan
Pavithra Saravanan

Posted on

Step By Step Code Execution in Java (using linux)

The developer or programmer writes the code in a human-readable format. Java compiler compiles it into byte code.
Byte code is not the machine executable code and hence, requires an interpreter to interpret it. The interpreter is the Java Virtual Machine (JVM) that executes the Byte code.

Compilation and execution
Two step process that involves converting the source code into executable code.

The first step compile the source code into byte code using Java compiler (javac)
Execution step is to run the byte code using JVM.

To fix your Linux after installation

Step 1: Go to update manager

Step 2: Install updates Check its upto date

Step 3: Select view and click linux Kernels.

Step4: Warning pop up will appear click continue then check whether it is in latest version.

Step 5: Now your Linux Os is ready to use.

In linux open text editor
Select edit and click preferences
In Display check the display, line numbers.
Choose plugins and check the needed checkbox.

Now type the code in text editor:

public class First
{
public static void main(String[] args)
{
System.out.println("Welcome To Java");

}

}

*After typing the code press ctrl+s

*Pop up will appear click documents create a folder and name it after that keep a file name most important thing keep he class name as file name.

Open the terminal and type is to view the list of documents.

Now go to files and choose doc folder (B14) in that
right click and press open in terminal

The terminal will be opened type the command javac First.java
It will ask to install jdk in that choose the option yes.

After that list of jdk will appear in that select and copy sudo apt install default - jdk.

Please wait for few minutes until it gets completed then type the comand java filename.

Output will appear:
Welcome to java
Java first change the source code into byte code then convert into binary code.

 compiler
Enter fullscreen mode Exit fullscreen mode

will check error
and trans into byte code
Java --------------> Byte code -------> Binary code

     Checking error
       compiler
Enter fullscreen mode Exit fullscreen mode

.java file ---------> .class file --------> common for all
platforms.

Top comments (0)