Archive

Posts Tagged ‘NetBeans’

Best practice: Use UTF-8 as your source code encoding

September 22nd, 2011 joconner No comments

Logo60s2

Software engineering teams have become more distributed in the last few years. It’s not uncommon to have programmers in multiple countries, maybe a team in Belarus and others in Japan and in the U.S. Each of these teams most likely speaks different languages, and most likely their host systems use different character encodings by default. That means that everyone’s source code editor creates files in different encodings too. You can imagine how mixed up and munged a shared source code repository might become when teams save, edit and re-save source files in multiple charset encodings. It happens, and it has happened to me when working with remote teams.

Here’s an example, you create a test file containing ASCII text. Overnight, your Japanese colleagues edit and save the file with a new test and add the following line in it:

String example = "Fight 文字化け!";

They save the file and submit it to the repository using Shift-JIS or some other common legacy encoding. You pick up the file the next day, add a couple lines to it, save it, and BAM! Data loss. Your editor creates garbage characters because it attempts to save the file in the ISO-8859-1 encoding. Instead of the correct Japanese text from above, your file now contains the text “Fight ?????” Not cool, not fun. And you’ve most likely broken the test as well.

How can you avoid these charset mismatches? The answer is to use a common charset across all your teams. The answer is to use Unicode, and more specifically, to use UTF-8. The reason is simple. I won’t try hard to defend this. It’s just seems obvious. Unicode is a superset of all other commonly used character sets. UTF-8, a specific encoding of Unicode, is backward compatible with ASCII character encoding, and all programming language source keywords and syntax (that I know) is composed of ASCII text. UTF-8 as a common charset encoding will allow all of your teams to share files, use characters that make sense for their tests or other source files, and never lose data again because of charset encoding mismatches.

If your editor has a setting for file encodings, use it and choose UTF-8. Train your team to use it too. Set up your ANT scripts and other build tools to use the UTF-8 encoding for compilations. You might have to explicitly tell your java compiler that source files are in UTF-8, but this is worth making the change. By the way, the javac command line argument you need is simply “-encoding UTF-8″.

Recently I was using NetBeans 7 in a project and discovered that it defaults to UTF-8. Nice! I was pleasantly surprised.

Regardless of your editor, look into this. Find out how to set your file encodings to UTF-8. You’ll definitely benefit from this in a distributed team environment in which people use different encodings. Standardize on this and make it part of your team’s best practices.

“Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the United States and other countries.”

VN:F [1.9.22_1171]
Rating: 2.3/5 (3 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Categories: Java, NetBeans, Unicode Tags: , , ,

NetBeans 7 has no UML tools?

August 20th, 2011 joconner No comments

After mentioning earlier that I am using Omnigraffle to create UML diagrams, I remembered that NetBeans once had a decent UML tool. Unfortunately I haven’t been able to find anything for the most recent NB 7 or 7.0.1 version. Oddly, the NetBeans page itself refers us to JDeveloper for UML support. Why point me to JDeveloper? I really want to use NetBeans.

The same page above also recommends a 3rd party plugin from Visual Paradigm, but Visual Paradigm seems limited to NB 6.2 if I’m reading its page correctly.

My suggestion for the above “UML support” page is this…just remove it. Having the page refer to out-of-date plugins or different IDEs altogether is no help. NetBeans crew, you know I love the product, but I also have to say it how it is. If there’s no current UML plugin, just say that and maybe give us an indication whether one is in the pipeline. Don’t tease me with a support page that points to other IDEs and outdated, presumably non-working 3rd party plugins for older versions.

VN:F [1.9.22_1171]
Rating: 4.9/5 (9 votes cast)
VN:F [1.9.22_1171]
Rating: +14 (from 14 votes)
Categories: NetBeans, Tools Tags: ,

NetBeans vs Eclipse for Maven Projects

August 1st, 2011 joconner No comments

I thought yesterday that I had pumped up NetBeans unfairly without regard to other tools. To be fair, I decided today that I’d try to open up the very same project in Eclipse, just to see if it matched NetBeans’ ability to immediately understand the project.

First thing I noticed was that Eclipse did not automatically understand Maven. A quick search of “maven plugin eclipse” put me in contact with a couple plugins. I tried the first one. Installed it like Eclipse likes by pointing to the plugin repo. Downloaded the plugin and then restarted eclipse. I thought Eclipse would behave like NetBeans on this, but no it didn’t. No good; the plugin options, if they even exist, don’t appear anywhere in the menus.

So, back to the search. I find another maven plugin. This time, I’m more successful installing the “m2eclipse” plugin. It actually exposes a “Maven” project in the menu system this time. So I point to my source code, and try to open the pom file. It opens the pom file, but it doesn’t open up all the modules or seem to understand that I want to see the source code in my ide. Hmmm, I wonder if I’m just not doing something right.

Of course, I’m not doing something right. I’m really a maven newbie. If I really knew what I was doing, I’d have this project up and humming in only minutes. Instead, I’ve been fiddling around with Eclipse for 1.5 hours, trying to figure out how to open an existing maven project in the tool. I can’t show anything productive for my labor. I’m disappointed.

So I go back to NetBeans, wondering if what I did before was something special. I did nothing but point NetBeans at the file directory, chose the File->Open Project menu and pointed it to the root directory of my Maven project. NetBeans just understands this is a Maven project. And I downloaded how many plugins? None, nothing at all. Worked right out of the box…again.

Yes, I know I didn’t give Eclipse a fair shake this time either. But why should I at this point? I can become an expert in Maven later and learn whatever it is that I need to integrate Eclipse later. But I have coding to do now, and don’t have time to mess with Maven. I have to work on my actual product, and time wasted on integrating my IDE with it is just wasted time.

Gotta love NetBeans. It just works.

VN:F [1.9.22_1171]
Rating: 3.7/5 (7 votes cast)
VN:F [1.9.22_1171]
Rating: +6 (from 6 votes)
Categories: Java, NetBeans, Tools Tags: ,

NetBeans 6.5, your IDE, your community

November 26th, 2008 joconner No comments

NetBeans 6.5

Several months ago, I submitted a bug against NetBeans 6.1. Sure, I expected someone to see the bug, but I didn’t expect the real and substantial interactions that followed.

After logging the bug, I received an email thanking me for my submission. A couple days later, when a NetBeans engineer was able to evaluate the problem, I received another email…this time with comments and even questions just for me. I responded. The NetBeans team responded and made comments on the bug report. The team engaged me, asked questions, and took my feedback seriously.

What an amazing experience! I was impressed by the team’s commitment to engage with its community, to interact directly with an individual.

Just yesterday, I received another email…this time to let me know that the bug fix is in NetBeans 6.5. The NetBeans community didn’t forget about me. I guess someone figured that I’d want to know the status of a bug…especially since I took the time to report it in the first place. They were right; I was interested.

I’ve always known that I’m a NetBeans user, but I would never have gone so far as to call myself a community member. I feel differently after this experience though. I’m glad to be part of the NetBeans community. If you use NetBeans, you’re part of the community too!

As a community member, exercise your rights to be influential in shaping NetBeans. You use NetBeans. Now do something to shape it and to improve it.

How can you get more involved in the NetBeans community? Here are some ideas:

Getting involved is easy, and there are dozens of ways to participate in this thing we call the NetBeans Community. Pick one of these suggestions, or find your own way to contribute. It’s really pretty simple to get involved.

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Categories: NetBeans Tags:

Changing project encodings in NetBeans 6.5

August 23rd, 2008 joconner No comments

I reported that NetBeans 6.1′s project charset encoding feature would allow an unsuspecting user to destroy file data. That’s still true…through no fault of NetBeans really. It’s just a matter of fact — if you start out with UTF-8 and convert your project files to ASCII or ISO-8859-1 or any other subset of Unicode, you will lose any characters that are not also in the target charset.

Read more…

VN:F [1.9.22_1171]
Rating: 0.0/5 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Categories: NetBeans Tags: