There are three flavors of Java: ME for mobile, SE for desktops, and EE for enterprise.

"Java is portable" refers to the SE version. It means that you can run Java bytecode on any hardware that has a compliant JVM.

It doesn't mean that ME is the same as SE is the same as EE. EE has EJBs, but SE and ME don't. That does not make them less portable.

C++ language doesn't change in all platforms.

This statement is not strictly correct. Microsoft adds extensions to their C++ that won't run elsewhere.

ANSI C++ might mean portable source code, as long as you stay away from platform-specific extensions. It does not mean portable bytecode; you may have to recompile and relink.

You want to run genetic algorithms on phones? I know that mobile devices have become pretty powerful, but I'm educated to think that GA would be a server-side functionality. Mobile devices feel more like view to me.

Answer from duffymo on Stack Overflow
Top answer
1 of 7
20

There are three flavors of Java: ME for mobile, SE for desktops, and EE for enterprise.

"Java is portable" refers to the SE version. It means that you can run Java bytecode on any hardware that has a compliant JVM.

It doesn't mean that ME is the same as SE is the same as EE. EE has EJBs, but SE and ME don't. That does not make them less portable.

C++ language doesn't change in all platforms.

This statement is not strictly correct. Microsoft adds extensions to their C++ that won't run elsewhere.

ANSI C++ might mean portable source code, as long as you stay away from platform-specific extensions. It does not mean portable bytecode; you may have to recompile and relink.

You want to run genetic algorithms on phones? I know that mobile devices have become pretty powerful, but I'm educated to think that GA would be a server-side functionality. Mobile devices feel more like view to me.

2 of 7
10

Every hardware architecture has its own somewhat unique instruction set (add ax, bx...) when you build a C++ code, the compiler turns it into a machine code specific to the system/architecture you are working on. So you have to customize and build your code for different architectures for it to work on them.

But What happens in java is, When you build it, it is compiled into a Byte code (as opposed to machine code). And the java virtual machine(JVM) interprets the Byte Code into an instruction that is understandable by the specific architecture you the program is running on. There is JVM for every major architecture and operating system so the code you write on windows will be interpreted and run on MAC-OS or linux without any source level modification by you. That is why Java is portable and that is where the Write Once Run Everywhere motto comes from

🌐
Quora
quora.com › What-is-portable-in-Java
What is portable in Java? - Quora
Portability is the ability to run a piece of [compiled] code without modifications when you run it from different architecture, platform, operating systems. So, yes, your Java Code could be portable as long as you have a JVM in that System.
Discussions

java - What is exactly the meaning of "portability"? - Software Engineering Stack Exchange
A program begin to inter-operate ... loaded into memory or even before that. Implementation of linkers and loaders employed by different operating systems decides format and portability of the executables. ... Java is object-compatible. You compile it on one patform and the resultant class files can run on any JVM. C is source-portable. You can take your C source code and compile it on any ISO C compiler, provided you follow the rules - that means no using undefined ... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
February 24, 2011
Why is C (or other similar programming languages) called portable if we need to code compilers for all platforms?
Although it's far from the norm nowadays, back when C was invented, many programming languages were tied to specific processors or families thereof so if you wanted the same program to run on different machines with different architectures, you had to rewrite the program in different programming languages, maintaining multiple code bases. C is portable in that you can write code without any consideration for a specific CPU. The need to write a compiler (or interpreter) for C to target a particular ISA is not unique to C. It's something that holds true for pretty much all portable programming languages. More on reddit.com
🌐 r/learnprogramming
9
2
March 8, 2023
Why is Java considered more portable than other languages like C++? - Software Engineering Stack Exchange
Sometimes even the most common ... to be portable as it is, you need less resources to port your program, that's it, whether said resource is money, time or manpower doesn't matter, it's a lower threshold compared to other technologies and that's what Java is for, it is lowering that threshold . Of course this is true if you accept the premises of Java, which means a virtual ... More on softwareengineering.stackexchange.com
🌐 softwareengineering.stackexchange.com
September 27, 2011
Appreciation for Java portability
Yep, there is no match for Java's portability. Even though Python gets the cake these days for portability too, I think Java was the one who pioneered the whole thing back in 1990s when going portable was almost like a rocket science. And apart from portability, another award goes to Java for maintaining backwards compatibility. Almost every other projects have had hiccups in this regard, but the JCP's process of slow and conservative updates and feature additions while ensuring compatibility is a commendable job which is rarely seen these days. More on reddit.com
🌐 r/java
33
135
December 18, 2023
🌐
Medium
rameshfadatare.medium.com › why-is-java-called-portable-bc714e1ccc7f
Why is Java Called Portable?. Java is often praised for being… | by Ramesh Fadatare | Medium
March 21, 2025 - Java is called portable because Java programs are compiled into bytecode, which can run on any machine that has a Java Virtual Machine (JVM). This means the same Java program can run on different operating systems without being modified or ...
🌐
Oracle
oracle.com › java › technical details
The Java Language Environment
Instead of pointer arithmetic, Java has true arrays and strings, which means that the interpreter can check array and string indexes. In addition, a programmer can't write code that turns an arbitrary integer into an object reference by casting. While Java doesn't pretend to completely remove the software quality assurance problem, removal of entire classes of programming errors considerably eases the job of testing and quality assurance. Java--an architecture-neutral and portable programming language--provides an attractive and simple solution to the problem of distributing your applications across heterogeneous network-based computing platforms.
🌐
Just Academy
justacademy.co › blog-detail › why-java-is-portable
Why Java is Portable
May 2, 2024 - Java is considered portable because of its “write once, run anywhere” principle, which allows Java code to be compiled into platform-independent bytecode that can be executed on any device with a Java Virtual Machine (JVM).
🌐
Medium
medium.com › gangboard › why-java-is-portable-1dab8b6756c3
Why java is portable:. Java: | by Jaya Priya | GangBoard | Medium
April 22, 2019 - · The idea is that the Java language is portable (or, more precisely, the compiled byte code is portable). You are sure that each VM requires a specific implementation for a certain hardware profile.
🌐
Java Guides
javaguides.net › 2024 › 09 › why-is-java-called-portable.html
Why is Java Called Portable?
September 10, 2024 - The main reason Java is portable is due to its use of bytecode and the Java Virtual Machine (JVM). When you write and compile a Java program, the code is translated into bytecode. This bytecode is platform-independent, meaning it is not tied to a specific computer or operating system.
Find elsewhere
🌐
InfoWorld
infoworld.com › home › careers › engineer
Java’s three types of portability | InfoWorld
May 1, 1997 - Running a given program on different ... people refer to Java applications and applets as portable, they usually mean the applications and applets run on different types of machines with no changes (such as recompilation or tweaks to the source code)....
🌐
Techshelps
techshelps.github.io › MSDN › BACKGRND › html › msdn_javaport.htm
Let's Talk About Java Portability
Portability implies ease of recompiling your software so you can run it on another platform, whereas (in the definition that Java has helped establish) cross-platform means compiling your code once and being able to run it anywhere (or, as the detractors say, compile it once, test it everywhere, ...
🌐
Reddit
reddit.com › r/learnprogramming › why is c (or other similar programming languages) called portable if we need to code compilers for all platforms?
r/learnprogramming on Reddit: Why is C (or other similar programming languages) called portable if we need to code compilers for all platforms?
March 8, 2023 -

For C to be portable on system X, we need to write a compiler for that system X. Does that makes C unportable on system X. What exactly is definition for portability of a programming language?

🌐
Kiuwan
kiuwan.com › blog › what-is-code-portability
A Guide to Code Portability | Kiuwan
January 7, 2026 - Several variables can impact code portability, particularly the systems your code interacts with and the assumptions it makes about its execution environment. The following factors have the most significant impact on whether your code can easily move across environments. Your choice of programming language shapes how portable your application can be. Languages like Java and Python are often easier to adapt across systems because they run on virtual machines (JVM, Python interpreters) rather than being tightly coupled to the underlying hardware or OS.
🌐
Quora
quora.com › Why-is-Java-portable
Why is Java portable? - Quora
Answer (1 of 7): Java is called portable because you can compile a java code which will spew out a byte-code, and then you run that code with Java Virtual Machine. Java Virtual Machine is like an interpreter, which reads the compiled byte-code ...
🌐
Tpoint Tech
tpointtech.com › what-is-portable-in-java
What is portable in Java - Tpoint Tech
March 17, 2025 - In the substantial panorama of programming languages, Java has earned its stripes as a versatile and platform-independent language.
🌐
Javatpoint
javatpoint.com › what-is-portable-in-java
What is portable in Java - Javatpoint
What is portable in Java with java tutorial, features, history, variables, programs, operators, oops concept, array, string, map, math, methods, examples etc.
🌐
Princeton
cs.princeton.edu › courses › archive › spr00 › cs111 › labs › introJava › 3.html
Programming in Java
Most application programs that you use are in machine-language and are not portable. If you were to copy the word processor from your Intel PC to, say, a DEC Alpha workstation, it would not run there. Why? Because the same numbers that represent the machine code for a useful working program on your Pentium chip will represent a seemingly nonsensical "gibberish" program on the Alpha chip. However, programs written in Java are portable.
Top answer
1 of 12
33

Java is compile once run anywhere. C++ is write once compile anywhere.

2 of 12
25

"writing a specific JRE for each platform" is not something you do everytime. Porting the JRE to a new platform is something you need doing only once. This task is generally done by the core maintainer/developers of the program and/or the platform. A lot of factors may come into play when deciding who and how the JRE would be ported. Among other things, it depends on the licensed it's published under (I hear Java is Open Source, so I guess anyone could do it). Funny anecdote, Steve Jobs made a big deal about not wanting to take care of the porting of Java on Mac, around a year ago.

The point is not how or who ports the JRE, but the fact that once it is ported, every Java application should now theoretically run easily on the new machine. In that sense, the JRE forms an abstraction layer, completely hiding the machine, allowing easy porting.

However, reality is not always pretty like this. I won't go as far as calling portability a "myth", but it's true that it's not so perfect. For instance, Java has a package called JNI that allows sending native calls, bypassing the JRE, thus preventing the perfect seamless portability, what Java fans like to call "Write once run everywhere".

As mentioned in the comments, C++'s approach to portability is different. On the one hand, it's a compiled language, and those binaries are almost always platform specific. So c++ executables will never be portable (unlike Java). On the other hand, porting the compiler can sometimes be enough. The community has found that by porting the compiler as well as some core libraries of the language, source codes (and not binaries) could be portable.

However, C++ is widely used in critical systems like compilers, kernels, real-time systems,embedded systems, ... There's a "low level" aspect of C++ that cannot be overlooked, when talking about portability.

🌐
Studocu
studocu.com › bethel college (kansas) › computer programming i › jav101: understanding the portability of java programming language
JAV101: Understanding the Portability of Java Programming Language - Studocu
May 1, 2023 - Lecture notes in Why Is Java Portable why is java portable? mentioned few times that java is portable and that java programs can run on any operating system. it
🌐
Reddit
reddit.com › r/java › appreciation for java portability
r/java on Reddit: Appreciation for Java portability
December 18, 2023 -

Just wanted to post on here to say I was actually shocked a couple of days ago when I finished my application, built the jar, and could run it seamlessly across OSs without any issues.

I wrote a patient record system using swing for the gui and a custom file type and encryption for data storage. Took me a few months of work but finally got it all working, held my breath waiting for the jar to build, expecting errors and compatibility issues but to my surprise - nothing. Seamless.

JVM is damn good! Didn’t appreciate it as a student but I really do now.

TL,DR: JVM is great.

Top answer
1 of 5
46
Yep, there is no match for Java's portability. Even though Python gets the cake these days for portability too, I think Java was the one who pioneered the whole thing back in 1990s when going portable was almost like a rocket science. And apart from portability, another award goes to Java for maintaining backwards compatibility. Almost every other projects have had hiccups in this regard, but the JCP's process of slow and conservative updates and feature additions while ensuring compatibility is a commendable job which is rarely seen these days.
2 of 5
9
A while back there was an issue with the Amazon SDK for Java where you couldn't run it on Docker alpine based images because it was trying to use openssl for some of its encryption routines (This had to do with the routines needed to support a new signature generation on requests if I recall). And Alpine images didn't come with openssl installed on it because the library was not compatible with musl C libs (I think). And the maddening thing was that what they were using openssl for was completely supported in Java JCE or bouncycastle libs. If Amazon had just declared the dependencies, written the code in Java and dropped openssl it would solve the issue completely. It was an artificially created limitation by NOT taking a WORA first attitude. It's also one of the reasons I always look for a Java solution first before installing Linux packages whenever I'm looking for libs because with Java dependency resolution in Maven and Gradle there is significantly less setup required in Devops land if I can stay in Java eco-system. I don't think the Java community realizes how beneficial WORA really as a feature.