What can make Java application platform dependent?

I am developing an application and wonder what can cause the app to be platform dependent. For example, using Windows path in the app make it app that runs only in Windows.

Upvotes: 3

Views: 157

Answers (1)

GhostCat
GhostCat

Reputation: 140613

There are plenty of things that can get you there:

  • using JNI to make native calls to OS specific features (like: reading/writing values to the windows registry)
  • relying on libraries ... that do make such native calls for you

The more subtle version of the same, especially in the context of GUI programming:

  • relying on specific (non standard) fonts
  • relying on OS specific plafs

As you have written in the question:

  • "external" identifiers that only work in a platform specific way, like: filepaths

The good news here: all of that is rather explicit. You have to write your code in a certain way to become platform dependent.

What is much harder, but luckily less common: writing valid Java code ... that in the end, relies on specific implementation details of the underlying JVM. For example threads are mapped to the threads that your OS provides. So, theoretically, there is a chance to write java code that behaves differently on different platforms.

Also note that there are in fact various different JVM implementations that matter in todays business world. Which can again result in different behavior at runtime.

Long story short: don't worry too much. When you follow standard best practices (for example: by avoiding fully hardcoded absolute path names), then your "medium sized" project should not have platform issues. But as soon as you are talking about really large, complex applications, things can be different, in many subtle ways.

Upvotes: 5

Related Questions