Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the meaning of "Java is portable"?

I'm confused about Java portability. If the Java language is portable, why is enum unknown in J2ME?

In C++, it's not important which platform or library is used. The "C++ language" doesn't change in all platforms.

My purpose is developing a Java library that just uses primitive types like int, String, or Array (something like a library for Genetic algorithms). I want to use this library in mobile and desktop applications. But it seems that enum and some other keywords do not exist in all platforms.

So I think I misunderstood the meaning of "Java portability". What does that mean?

like image 962
Amir Saniyan Avatar asked Oct 25 '12 12:10

Amir Saniyan


People also ask

What does it mean when Java is portable?

When 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).

Why Java is portable and secure?

Java is secure due to the following reasons: Java programs run inside a virtual machine which is known as a sandbox. Java does not support explicit pointer. Byte-code verifier checks the code fragments for illegal code that can violate access right to object.

What does it mean when a programming language is portable?

Portability is a characteristic attributed to a computer program if it can be used in an operating systems other than the one in which it was created without requiring major rework. Porting is the task of doing any work necessary to make the computer program run in the new environment.

Is JVM portable?

The JVM manages system memory and provides a portable execution environment for Java-based applications. The Java Virtual Machine is a program whose purpose is to execute other programs.


1 Answers

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.

like image 158
duffymo Avatar answered Sep 23 '22 19:09

duffymo