Question of the Week #27
What does "write once, run anywhere" refer to in Java?
22 messages · Page 1 of 1 (latest)
What does "write once, run anywhere" refer to in Java?
Programming in the Java language allows you to be able to run the Java Application in windows, Linux and MacOS.
The "write once, run anywhere" refers to when java was made all platforms could use it so if you have a mac you could write code on there, then save it and go to a windows computer and open the file it would run. Giving it the quote "write once, run anywhere'
The saying "write once, run anywhere" refers to the fact that Java compiles and gets interpreted by the Java Virtual Machine, instead of a specific OS, and therefore any machine that has the Java Runtime Environment can run Java applications, no matter the OS.
When our source code is compiled in Java, the compiler then converts our source code into byte code. Now this byte code can be executed on any operating system using Java virtual machine(JVM).
It refers to the fact that Java is a compiled langage that is interpreted by a virtual machine called JVM, every system that has a JVM can run java code. This means that we can write java on a machine and run the same code on another machine.
(i think hehe)
The JVM was designed to make Java code compatible on basically every platform in existence. When you write Java code once, it can be ran on any other platform. That's the surface of it.
It represents how java is special in when the code is compiled it can be run anywhere, unlike other languages such as C# which need to be compiled on each device/instance they are run on.
it reflects the nature of javas ability to run on any system that supports Java Virtual machine because with the JVM you can compile java to bytecode and then run it on any device without needing to change or recompile.
Write once, run anywhere usually refers to Java's ability to abstract system-specific functionality and be run by VMs for the specific platform the program is supposed to run on, letting the developers of said program focus on the actual functionality rather than focusing on what environment they are running on.
At least that's my take on it :D
The JVM is what is referred to. Code generated by C or C# programs output executables that can only be run on certain OS. C# for example outputs a .exe file, which can only be run on windows. However, when Java (or any other JVM language) outputs a JAR file, it can be run if the JVM has been installed on that machine. The JVM basically allows for the execution of and JVM language on any platform, no matter the OS.
The statement "write once, run anywhere" refers to the fact that Java is platform-independent, which means that it can run on any operating system or device as long as the Java Virtual Machine is installed.
Highlights platform independent feature of Java. The byte code generated after compilation can run on any system's JVM
Java is a language that works on many devices including every OS and all you have to do is install java for example I make a hello world program and if I compile it into a jar file I can run it on every device with java installed as long as the jar file works the reason for this is because Java uses bytecode when compiled using the JVM to compile .java to .class and and a .class file is basically just a bytecode version of .java and .jar is the .class file made into a executable file. This all is possible by bytecode and the JVM
It means java can run any platform (cross platform) whether it be mobile, web, desktop, etc..
It's means that the after the jvm compiles the our code it's provides us with byte code which is platform independent and could be run on any platform
java bytecode runs in the jvm which is supported by many platforms
you write the code once, it's converted to java bytecode and can be ran on any supported platform
Write Once Run Anywhere, is the feature applicable to those programs which hold the capability to execute itself on any operating systems or any machine.
If they were being honest, they really should have said "write once, run anywhere that we've written a JVM for" since the JVM actually is platform dependent, like any standalone software would be, and you can only run your java application on a machine that has a JVM available to run your software. However, in reality, almost everything is running either mac, linux or windows, so if you write java app, it can run "basically" anywhere.
What lets it do this is the fact that your java app isn't actually compiled into machine code like a standalone app, it's compiled into "java bytecode". In other words, you're not writing code that tells the machine what to do. You're writing code that tells **the java JVM **what to tell the machine to do. So the JVM, whichever platform version is running, can take your instructions and interpret it into the correct machine instructions to perform on whatever platform your java app is running on. It's like a translator.
Which is super convenient. It means you just write your code once, compile it into java bytecode, and the JVM will do the hard work of converting those instructions into platform dependent machine code instructions. Which is what they mean when they say "write once, run anywhere". Since you don't have to worry about writing separate apps specific to each OS if you're writing them in java.