Forcing NetBeans to Use Unix (LF) Line Endings

NetBeans usually uses the operating systems default line ending when creating a new file (it establishes this by what the JVM tells it). So for example in Windows it will automatically use CRLF and in Unix it will automatically use LF. This behaviour has its advantages, but sometimes you want to to be specific about the line endings you need.

To do this you can add the following switch to your call to the NetBeans binary. On Windows this would be done on the shortcut by opening its properties and adding the switch at the very end of the Target line.

-J-Dline.separator=LF

Whilst this is handy a proper setting in the preferences of NetBeans would be preferable as it could then easily be backed up and taken from machine to machine. Vote for the issue on the NetBeans bug tracker.