Java Development
As a java development company, we simply run our java program by hitting the run button but have you ever considered in what step our program passes.Today you are at the right place where we will delve you in the internal working of JVM.We will also get to know some interesting point about JVM.
Acronym of JVM - Java Virtual Machine.
- JVM is a program not a machine.
Suppose if we write a C/C++ program then it goes to the following phases.Suppose the program name is Test.
Test.c →Test.obj → Test.exe → Test Output
If It has the right process of running the program then what is wrong with this procedure. The main problem is platform Independence. If we write a C/C++ program with a pentium or spark processor then the instruction of the program will be understandable by only a pentium or spark processor because every processor has their own instruction set that they may follow. Let's say, for adding two numbers spark processor may follow instruction add a,b or the celeron may follow as a add b . so every processor has their different instruction set. If we write a program using a spark processor then it may not be understood by the celeron process or vice-versa because there are several flavours of processor available in the market .
Another problem is size. Suppose we write a C/C++ program Test.c . This Test.c file contains the source code . When we compile this program then we get Test.obj that contains the machine language code,which is just equal to source code.suppose the first statement is of including a header file, like<stdio.h>. When we run this program then it will first go to the c standard library(generally available in tc\lib). It first searches for the header file(code is in format of machine language) and copies the code into our c program.so, if our code is of 5 lines and the header file code is of 500 lines then the program size will be 505 lines. This file is also known as Test.exe file.so every time it will copy the code and this may increase the program size. if we are developing a large program for example military or satellite program then the code size will increase unnecessary.
In java if we write a java program,it stores as extension .java. Suppose if our java program name is Test.java . When we compile the java program it first translates the Test.java to Test.class which contains the byte code instruction which can be neither executed or understood by microprocessor then these byte code instructions are meant for whom ? They are for JVM . Here the JVM role is very crucial because it first identifies the operating system and processor then converts the byte code in an understandable format for that particular processor and operating system.
Test.java → Test.class → JVM(Convert byte code to machine code) → Output
So if we write a Test.java program with a celeron processor and when we compile this program it will produce a Test.class file that contains the byte code instruction and when this is given to the JVM . It first identifies that processor and operating system and converts this byte code into machine language code understandable by the celeron processor.That’s why we call Java a system independent language.
Remember JVM is a program and several flavours are available on the internet and can be downloaded from the internet.
On the internet, different computers with different processors are available.We can share .class files on the internet and this file will produce the same result on every machine. Hence java is suitable for programming languages for software development on the internet.
In the era of internet,most of the virus can be spread using .exe,.doc,image(.gif,.jpg),audio,video files but viruses can’t be spread with a .txt file . In java .class is equal to the .txt file hence there is no chance of affecting these files.even if somebody tries to affect these files, JVM can verify its presence before running the program and abort the execution of .class file.
Virtual Thread - As we are aware that java is a multithreading language.Thread actually helps the processor to improve efficiency,memory utilisation and performance.virtual thread concept came in jdk 19 and now it is stable.virtual thread is not dependent on operating system.virtual thread provides the high throughput.
String Templates - it's a new feature of java 21. Earlier while forming a message with static and dynamic value is become so cumbersome process for example
int a =10;
Int b=20
String response = “Sum of “+a +” and ”+b+” is=”+(a+b);
There are other several ways for string concatenation like- + Operator,String buffer,String builder,MessageFormat,String formatter but why should we use string template? Let's have a look.
Now with String template -
String response = STR.”Sum of \{a} and \{b} =\{(a+b)}”;
There are lots of features that ease the development like Unnamed variable,Stream api,Emoji support,Markdown comment support,developer support,Security enhancement etc.
Java's enduring popularity lies in its platform independence, robust security features, and continuous evolution with new functionalities like virtual threads and string templates. Its ability to seamlessly adapt to different operating systems through the JVM makes it ideal for internet-based applications. As a reliable choice for both web and enterprise solutions, Java development remains a cornerstone for businesses looking to build scalable, secure, and efficient software. Whether you're exploring new features or leveraging its mature ecosystem, Java offers the tools and flexibility needed for modern development challenges.