Understanding Java Compiler and Java Virtual Machine – Part 4

Till now we have gone through working and code structure of Java and Class, Main method & Loop Control in Java. Here in this post we will see What is Java Compiler and Java Virtual Machine. What are they meant for and their roles.

Understanding Java Compiler and Java Virtual Machine
Understanding Java Compiler and Java Virtual Machine – Part 4

What is Java Compiler

Java is a strongly typed language which means variable must hold right kind of data. In a strongly typed language a variable can not hold wrong data type. This is a safety feature very well implemented in Java Programming Language.

Java compiler is responsible for through checking the variables for any violation in data-type holding. A few exception may arise at run-time which is compulsory for dynamic binding feature of Java. As Java program runs it may include new objects that were not existing before hence to have some degree of flexibility a few exceptions are allowed in data-type that a variable can hold.

Java Compiler set filter for those piece of code that won’t compile ever except for the comments. Compiler do not parse the comments and leave it as it is. Java code supports three kinds of comments within Program.

1. /* COMMENT HERE */
2. /** DOCUMENTATION COMMENT HERE */
3. // COMMENT HERE

Anything that is placed between /* and */ or /** and */ or after // is ignored by Java Compiler.

Java Compiler is responsible for strict checking any syntax violation. Java Compiler is designed to be a bytecode compiler ie., it create a class file out of actual program file written purely in bytecode.

Java Compiler is the first stage of security. It is the first line of defense where checking for incorrect data-type in variable is checked. A wrong data-type can cause damage to the program and outside it. Also compiler check if any piece of code trying to invoke restricted piece of code like private class. It restrict unauthorized access of code/class/critical data.

Java Compiler produce bytecodes/class file that are platform and architecturally neutral that requires JVM to run and it will literally run on any device/platform/architecture.

What is Java Virtual Machine (JVM)

Java Virtual Machine is the next line of security which put an extra layer between Java Application and OS. Also it check the class file that has been security checked and compiled by Java Compiler, if someone tampered the class file/bytecode to restrict access to unauthorized critical data.

Java Virtual Machine interprets the bytecode by loading the class file to machine Language.

JVM is responsible for functions like Load and Store, Arithmetic calculation, Type conversion, Object Creation, Object Manupulation, Control Transfer, Throwing exception, etc.

The working model of Java in which Java Compiler compiles the code into calssfile/bytecodes and then Java Virtual Machine run the classfile/bytecode. This model ensures that code run at fast speed and the additional layer ensures security.

So what do you think – Java Compiler or Java Virtual Machine perform more important task? A Java program has to run through both the surface (Compiler and JVM) essentially.

This post sums the role of Java Compiler and JVM. All your suggestions are welcome in the comments below. We are working on the next post “object oriented approach of Java”. Till then stay tuned and connected to TecMint. Like and share us and help us get spread.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

Avishek
A Passionate GNU/Linux Enthusiast and Software Developer with over a decade in the field of Linux and Open Source technologies.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

3 Comments

Leave a Reply
  1. JVM allows Java portability to execute within platform and hardware-independent applications. many thanks for sharing this article.

    Reply
  2. When interest in virtual machinery began exploding in popularity, enabling so much in the Cloud storage ability, Networking in multiple device platforms, and in the limitless possible efforts developed in ap design since(bug fix, pre-run time, beta,etc…)itwas easy, even as a novice computer user(still have little clue) to see the potential in both possitive and negative usage.
    It has become a prevelent method by which email scams for compiling information/data and financial activity of nefarious origins are so prevelent now that I say,”p-sha!!!”
    Reading about the linux kernal earlier this year, and the many anomolys discovered in the brand new hp win8.1 laptop I received as a birthday present brought my attention to the basic principles which enable the loopback interface and java compiler to function as designed. Having had read virtual theory and aplicable practice, as well as beta testing since 11′ some of these platforms now regularly utilized now in almost every smartphone and computer which includes adobe or google+ storage and a number of other aps now grown huge since, all this enabled me to be far less unaware of those instances where recognizing the java platform’s flaw/s. These begin in the char created within the kernel, establishing a runtime bios not native to the initial bios initiated in factory design. As a result, and as a result of the incredible loss of data speeds, due to the compiler having to rewrite, in “realtime”, for its virtual java platform/ap/machine. This is alarming for several reasons:who would wish to enjoy the benefit of a birthday gift with 6g ram which opperates as if it carries 512mb?
    the char creates a gap of an exponentially large defenseless week point for anyone to further institute virtual runtime machinery compiled ether alongside, parented, or in a hidden/background process that ultimately creates an ownership conflict between the java compiler and the owner of the bios (owned wholey by the purchaser, and not so “open source” as to relinquish control without contractual agreement(something yet to become more than moot, as a resultof tech advancements, and java bottom line’s dependence in many ways upon this ambiguity.
    finally, it establishes a microsoft-like monopolly(similar to the early nineties) that can potentally arm the growth in tech advancements, as the auto industry and the combustable engine(compiler) may do in a like manner over time.
    Maybe, I am only proving how little I do know about computers by writing all of ghis, and maybe I am too novice to completely understand what I am seeing, reading, and imagining capable in the run time java environment, pre-java platform(kernel), and how little we know of what mathmatics et discovered may revolutionalize the next generation of advancements we make inthe tech industry(especially considering the fiber optic increases in data speads forthcoming here in tempe, az. Which would only further enable, lets say, a computer user anywhere in the world, to char the bios of another computer in tempe, and then take advantage of any of those just outside the grid of fiber optics, who are snails paces behind discovery that their data may be actively consumed by others before they even recognize they have data which can be taken(data being a comodity nowadays) by a “pirating” scam to network alterior phone options from verizon, t-mobile, sprint, etc…)
    My imagination just boggles my own mind, and I fear these are just iceberg tips.

    Reply

Got Something to Say? Join the Discussion...

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.