What do you mean by portable in java?? PLEASE HELP ME....

Dani AI

Generated

— in Java, "portable" means your compiled program does not need to be rebuilt for every operating system or CPU. Source is compiled into platform-neutral bytecode that runs on any conforming Java Virtual Machine (JVM), which is the core idea behind what described and what the platform documentation calls the "write once, run anywhere" approach. As hinted, searching helps, but here are the practical details to keep in mind. See the Java platform docs for background: Java Tutorials.

Portability is not automatic in every situation. Code that uses native libraries (JNI), spawns OS shell commands, assumes path formats or case sensitivity, depends on the default charset or locale, relies on platform-specific GUI behavior, or depends on a particular JVM version can break on other systems. Serialized objects can also be incompatible across builds or versions unless managed explicitly.

To improve portability, use standard Java APIs and platform-neutral helpers: prefer java.nio.file.Path and Paths.get for paths, use StandardCharsets.UTF8 and explicit Locale when parsing/formatting, use System.lineSeparator() for line breaks, avoid JNI and hard-coded absolute paths, declare serialVersionUID for Serializable classes, and test on the JVMs and OSes you intend to support (CI test matrix if possible). When distributing, bundle dependencies into an executable JAR or provide a controlled runtime to reduce environment differences. For a concise history of the portability goal, see the Java overview: [Java (programming language)](https://en.wikipedia.org/wiki/Java(programming_language)).

Recommended Answers

All 2 Replies

Or you could have done the same thing that adatapost did here and have found out the answer more faster.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.