NoSuchMethodError when deployed on linux NoSuchMethodError when deployed on linux windows windows

NoSuchMethodError when deployed on linux


It seems that you are not using the same version of Java between Linux and Windows.

As you can see in the javadoc, System.lineSeparator() doesn't exists in java < 7.

So, if you want to get the line separator on java < 7, you have to use:

System.getProperty("line.separator")


It seems that you are running different JDK versions on Windows and Linux.

  • On Windows the JDK is 7 which has System.lineSeparator() method defined.
  • The same method does not exist in the previous JDK verions (check System class in Java 6) which is running on your Linux box.

For the backward compatible code use System.getProperty("line.separator").


As others pointed out there is an issue with the versions.I would dare to say that merely changing the JVM is not enough.Your program could check for the expected version at startup to avoid such issues in the future:

String runtimeName = System.getProperty("java.runtime.name");String runtimeVersion = System.getProperty("java.runtime.version");... check if JVM is the expected one, log some informative message if not ...

You can also do this for other settings (Locale ...) but those depend on the nature of your project. The idea is that a dead program is better than a crippled one (fail fast), another idea is that you should fix an issue once and for all (find bugs once).You can find more tips here: http://pragprog.com/the-pragmatic-programmer/extracts/tips