Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

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.

 



Are you a Developer working with PDF files?

Our developers guide contains a large number of technical posts to help you understand the PDF file Format.

Do you need to solve any of these problems?

Display PDF documents in a Web app
Use PDF Forms in a web browser
Convert PDF Documents to an image
Work with PDF Documents in Java
Mark Stephens Mark has been working with Java and PDF since 1999 and is a big NetBeans fan. He enjoys speaking at conferences. He has an MA in Medieval History and a passion for reading.

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 *

IDRsolutions Ltd 2022. All rights reserved.