Welcome to the Joint-Venture Blog from Fabio Cortesi and Stefan Jäger.
I always wondered, how I can search and replace in multiple files with Eclipse. I always searched for a “Search & Replace” dialog. I never found one. But a search & replace in multiple files is possible. First, just perform a usual file search (CTRL + H). All the search results gets displayed in the “Search” view. And there, it is possible to replace the searched keyword in selected or all found files. Just do a right-click.
On the Eclipse homepage you will find a very nice description about all new features in Galileo.
In a view of a Java developer, there are not a lot of new features. German readers will find at jaxenter a nice article with all new Java features.
The only one, which seems noteworthy, is the new toString() wizard:
Source Control like CVS or Subversion is used almost in every software project. As a developer, it’s your responsibility to be up to date with the current version from the source control system. In Eclipse there is a nice feature to schedule such synchronizations. This means, you get regularly informed about all updates and you have less merging problems!
Today, I encountered a very helpful feature in Eclipse. When I am debugging code, I sometimes want to know, what’s the result of a method is. If the result it’s not assigned to a variable, it gets complicated. Take a look to this example: what is the result of add(17,19)?
public class DemoApplication { public static void main(String[] args) throws Exception { DemoApplication calc = new DemoApplication(); System.out.println(calc.divide(calc.add(17, 19), 2)); } public int add(int i, int j) { return i + j; } public int divide(int i, int j) { return i / j; } }
In earlier times, I stepped one step further to get into the method divide. Then I got the result of add(17,19) in my parameter.
In Eclipse, there is a nice feature to clean up Java code. First, you can change the Clean Up profile (Window – Preferences) and define, how you want the code should look like.
There are interesting clean ups like “Remove unnecessary casts” or to add missing Annotations like “@Override”.
After creating your profile, simply right click to the project and choose Source – Clean up.
Nice feature. If you want to know more about this feature, you will find here more information’s.
After the ultimate shortcut, which I mentioned here, there’s another nice shortcut in Eclipse: CTRL + 1. This shortcut helps you almost in every situation. Let me mention two examples (there a lot more, just try it out):
Use CTRL + 1 to assign a parameter of a constructor as a field:
Or use CTRL + 1 to extract a String or another variable to a constant:
Are you a real men (or women)? Because if you are one, Eclipse offers you the possiblity to “don’t click”
Try to use the simple shortcut CTRL + 3. What happens? Eclipse opens the Quick access window:
Now, type what you want, for example “new xml file”, and Eclipse searches for the command, which consists of these words:
Also very interesting is the access to the Preferences window. Try to search for “classpath variables” or “build path”, you get direct access to these settings. Also interesting is “Generate Getters”. If you don’t know a specific shortcut, just use CTRL + 3 from now on!
If you press CTRL + O in Eclipse, a list with all members and methods shows up. Red highlighted are private members/methods, green public ones. But unfortunately, inherited methods are invisible.
Now, just press CTRL + O again and you can see all inherited methods.
I know, the hint is mentioned in the bottom right corner, but I didn’t noticed this until today…
If you double click on a tab in Eclipse, the tab get’s opened all over the window. Now, if there is a build process running in the console, the console is always popping up. This is a little bit annoying. But there is a simple trick to solve this situation. Just disable “Show Console When Standard Out Changes” and the console will not pop up again.
Everybody, who’s working with Eclipse is knows the Content Assistant (better known as Code Completion). Just press CTRL + Space, and every possible piece of code gets completed.
But did you know, that Eclipse is also capable of using templates. Templates can be defined in Window – Preferences – Java – Editor – Templates.
For example, instead of typing the main function every time manually, just type main and press CTRL + Space, choose the template main and press Enter. The whole main method is created.
Interesting default templates are:
sysout: creates a System.out.println() entry
runnable: creates a complete Runnable inner class
public_method: template for a public method (same with private, default, and so on)
Of course, you also can define your own template. E.g. for an EJB 3.0 stateless or message-driven bean!
Older Posts »

