Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Why do IDEA and NetBeans give different output from my Java code?

42 sec read

I spend a lot of time using IDEA 11.1 or NetBeans 7.3 and switching between. So I like to be sure that they work in the way I expect and also give consistent results. I was intrigued to find that on my Mac, some tests gave slightly different output or each IDE….

Both of them are running the same JDK (1.7_07) with the same heap size. But my results were different. So I examined the changes and they were some altered text characters. The issue was that IDEA and NetBeans have been set to use different encodings for text characters on the Mac – NetBeans is on UTF8 while IDEA uses MacRoman encoding. Aligning them and bingo – I get identical results!

So it was a good reminder that there are other factors that can effect how your Java code works. Here are the 2 properties locations so you can align your values.

Do you have any tips for working with NetBeans and IDEA?

This post is part of our “NetBeans article Index” series. In these articles, we aim to explore NetBeans in different ways, from useful hint and tips, to our how-to’s, experiences and usage of the NetBeans IDE.

 

Mark Stephens

Mark Stephens has been working with Java and PDF since 1999 and has diversified into HTML5, SVG and JavaFX.

He also enjoys speaking at conferences and has been a Speaker at user groups, Business of Software, Seybold and JavaOne conferences. He has a very dry sense of humor and an MA in Medieval History for which he has not yet found a practical use.

Key Takeaways from Apache NetBeans Day UK

Apache NetBeans Day 2018 has come and gone. Whether you attended, watched it live or missed the event – we will take this opportunity...
Ovidijus Okinskas
2 min read

5 tips for getting the most out of Apache…

Apache NetBeans Day UK 2018 is fast approaching – Friday 27th April at the University of Greenwich. If you have not yet registered for...
Ovidijus Okinskas
1 min read

5 Replies to “Why do IDEA and NetBeans give different output from…”

      1. Thanks, I see. That’s why encoding should always be made explicit when using streams in Java. Default encoding (and default locale, for that matter) are only for those, who enjoy a daily surprise…

  1. Your post is a bit deceiving.
    You should have mentioned in the first place you wrote some non-Latin characters in the files.
    Or you should try renaming the post…you have to read half of it to find out that it’s about characters encoding.

    1. The whole point of the article was to remind people that there are several things like encoding which can lead to different results but which are easily overlooked. I did not know I had non latin characters until I drilled down to see what the problem was.

Leave a Reply

Your email address will not be published. Required fields are marked *