Chris Wade Chris developed much of the Forms handling code and also the hooks for the XFA.

Writing cleaner Java code with eclipse

1 min read

It is always helpful when a tool encourages you to write ‘good code’. Eclipse has some excellent plugins like PMD and FindBugs for analysing and improving your code. But did you know that Eclipse actually has some useful built-in tools to help you?

I found a useful feature of eclipse, to help me clean up my code before I test or commit any of it.
If you go to ‘Window’ -> ‘Preferences’

I’m sure you have been in here before,
But now go to ‘Java -> ‘Compiler’ -> ‘Errors/Warnings’

Now there are lots of useful clean code building features you can edit.

I use the Unused imports and local variables unread, as many times writing new code you add variables that you later end up not needing. This is a good way to highlight them to you. You can also set the options to show a warning or fail – so that your code will not compile and Eclipse will show an error. You will then have to actually fix the issue then and there.

It also allows you to turn all those annoying warnings off so that you can see the errors in the right side bar of your code display window (those blue and yellow, and sometimes red, square markers).

If you turn them all on, you will probably see loads of errors or warnings. So if you are new, a good strategy is to turn them on individually over a period of time and deal with the issues over a period of time. This also lets you test your changes gradually and reduces the chances of breaking something. It is a good end of day 15 minute task.

Do you have any favourite features that help you in developing your code?

Watch how to use our PDF Viewer JPedal

Chris Wade Chris developed much of the Forms handling code and also the hooks for the XFA.

The top 11 Free IDE for Java Coding, Development…

At IDR Solutions we spend a lot of our time working with Java as our JPedal Java PDF Library, BuildVu PDF to HTML5/SVG converter ...
Alex Marshall
7 min read

Leave a Reply

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

IDRsolutions Ltd 2022. All rights reserved.