Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts
Tuesday, December 18, 2012
Wednesday, September 1, 2010
Could not calculate build plan: Missing: maven-resources-plugin:maven-plugin:2.4.1
While I was trying to take Quartz using Maven I got "Could not calculate build plan: Missing: maven-resources-plugin:maven-plugin:2.4.1" error. What now? Everything was working just fine!
To fix this, find where your local repo is, then go to "/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/", remove "2.4.1" directory and do "update dependencies" from Maven.
To fix this, find where your local repo is, then go to "/.m2/repository/org/apache/maven/plugins/maven-resources-plugin/", remove "2.4.1" directory and do "update dependencies" from Maven.
Friday, August 20, 2010
eclipse keymap on intellij idea
As you probably know I'm a fan of Eclipse. In our current project, we are using IntelliJ Idea as ide. Obviously I want to use Eclipse shortcuts on IntelliJ Idea but how?
Open File > Settings > Keymap and change the keymap to Eclipse. You can set Netbeans shortcuts from there too.
Open File > Settings > Keymap and change the keymap to Eclipse. You can set Netbeans shortcuts from there too.
Tuesday, May 4, 2010
use maven on eclipse
Maven is a popular project management tool and it is quite practical to use it on Eclipse with the help of m2eclipse. To install m2eclipse in Eclipse:
- Help > Install New Software.
- Paste http://m2eclipse.sonatype.org/sites/m2e in "work with:" field and press enter
- Choose the only component listed under m2eclipse
- Click next and finish.
Saturday, October 10, 2009
refactoring my code (with a little help from my friend Eclipse)
In this post, I'll explain few refactoring tricks and we will use the help of Eclipse as much as possible. Here we go!
Above we create a list of items for each character and add them to an owner-item map. This piece of code is begging for refactoring.
First, I choose the piece of code I'd like to extract as a method.

Then I choose refactor>extract method.

I enter "generateVaderList" as method name and here's our refactored code.
No need for a temporary reference assignment so I can edit the below part;
to
If I do this refactoring for every character my code will be clearer. But think about it. If I do that I'll have three different methods with similar functionality. These methods create a list, add necessary elements to the list and return the list. What if I take these methods and write a more generic one instead of three methods with similar functionality? Later, if I'd like to add a new character I won't write a createNewCharacterList method. I'll use the generic one instead.
Lets see how we can make the method more generic. It creates a list and adds hard-coded strings to it. This method will be general if I hand it the item strings to add. First I choose the name of "createVaderList" and then right click. Then refactor>rename. I rename it as "createItemList". I'm writing a more general method, remember? I can change the method signature from the menu but this is not so handy so I'll skip that and edit my method by hand.
will become
In this new method, we -again- create a list. Then we take an arbitrary number of strings. I assure this behavior by using var-args. Then in our beautiful for-loop we add the items to the item list and return the list.
After that we will do the necessary changes in the code. Eclipse can't help us in this case. After we do the necessary changes in our code, our main method will be such as below;
Much clearer and more usable right?
Map<String, List<String>> personalItemsMap = new HashMapMap<String, List<String>>();
// for darth vader
List<string> vaderList = new ArrayList<string>();
vaderList.add("lightsaber");
vaderList.add("helmet");
vaderList.add("armor");
personalItemsMap.put("darth vader", vaderList);
// for han solo
List<string> soloList = new ArrayList<string>();
soloList.add("blaster");
soloList.add("vest");
personalItemsMap.put("han solo", soloList);
// for boba fett
List<string> bobaList = new ArrayList<string>();
bobaList.add("blaster");
bobaList.add("mandalorian armor");
personalItemsMap.put("boba fett", bobaList);
System.out.println(personalItemsMap);
Above we create a list of items for each character and add them to an owner-item map. This piece of code is begging for refactoring.
First, I choose the piece of code I'd like to extract as a method.
Then I choose refactor>extract method.
I enter "generateVaderList" as method name and here's our refactored code.
public static void main(String[] args) {
Map<String, List<String>> personalItemsMap = new HashMap()<String, List<String>>;
// for darth vader
List<string> vaderList = createVaderList();
personalItemsMap.put("darth vader", vaderList);
// for han solo
List<string> soloList = new ArrayList<string>();
soloList.add("blaster");
soloList.add("vest");
personalItemsMap.put("han solo", soloList);
// for boba fett
List<string> bobaList = new ArrayList<string>();
bobaList.add("blaster");
bobaList.add("mandalorian armor");
personalItemsMap.put("boba fett", bobaList);
System.out.println(personalItemsMap);
}
private static ListcreateVaderList() {
ListvaderList = new ArrayList ();
vaderList.add("lightsaber");
vaderList.add("helmet");
vaderList.add("armor");
return vaderList;
}
No need for a temporary reference assignment so I can edit the below part;
List<string> vaderList = createVaderList();
personalItemsMap.put("darth vader", vaderList);
to
personalItemsMap.put("darth vader", createVaderList());
If I do this refactoring for every character my code will be clearer. But think about it. If I do that I'll have three different methods with similar functionality. These methods create a list, add necessary elements to the list and return the list. What if I take these methods and write a more generic one instead of three methods with similar functionality? Later, if I'd like to add a new character I won't write a createNewCharacterList method. I'll use the generic one instead.
Lets see how we can make the method more generic. It creates a list and adds hard-coded strings to it. This method will be general if I hand it the item strings to add. First I choose the name of "createVaderList" and then right click. Then refactor>rename. I rename it as "createItemList". I'm writing a more general method, remember? I can change the method signature from the menu but this is not so handy so I'll skip that and edit my method by hand.
private static ListcreateItemList() {
List<string> vaderList = new ArrayList<string>();
vaderList.add("lightsaber");
vaderList.add("helmet");
vaderList.add("armor");
return vaderList;
}
will become
private static List<string> createItemList(String... items) {
List<string> itemList = new ArrayList<string>();
for(String item : items)
itemList.add(item);
return itemList;
}
In this new method, we -again- create a list. Then we take an arbitrary number of strings. I assure this behavior by using var-args. Then in our beautiful for-loop we add the items to the item list and return the list.
After that we will do the necessary changes in the code. Eclipse can't help us in this case. After we do the necessary changes in our code, our main method will be such as below;
public static void main(String[] args) {
Map<String, List<String>> personalItemsMap = new HashMapMap<String, List<String>>();
// for darth vader
personalItemsMap.put("darth vader", createItemList("lightsaber", "helmet", "armor"));
// for han solo
personalItemsMap.put("han solo", createItemList("blaster", "vest"));
// for boba fett
personalItemsMap.put("boba fett", createItemList("blaster", "mandalorian armor"));
System.out.println(personalItemsMap);
}
Much clearer and more usable right?
Friday, August 14, 2009
eclipse magic part 2: correct indentation automatically
Eclipse tries to offer a correct indentation while you're writing your code, but there are times it does not work well. In result, you got a less readable code. Either you have to correct its indentation by hand or you have to use the eclipse magic.
Now choose the lines you want to the indentation (or the whole text) and either do CTRL + I or Source > Correct Indentation. Here's the result:
for(Float number : numberList)
System.out.println(number); // need an indentationhere
Collections.sort(numberList, new FloatComparator());
System.out.println("------- after sorting takes place -----");
for(Float number : numberList) // need indentation for the
//two following lines
System.out.println(number);
Now choose the lines you want to the indentation (or the whole text) and either do CTRL + I or Source > Correct Indentation. Here's the result:
for(Float number : numberList)
System.out.println(number);
Collections.sort(numberList, new FloatComparator());
System.out.println("------- after sorting takes place -----");
for(Float number : numberList)
System.out.println(number);
Friday, August 7, 2009
eclipse magic part 1: automatically generate getters and setters for your instance variables
Everyone who tried to write a getter / setter (accessor, mutator) method for more than 2-3 fields knows that it's a pain. Eclipse can automatically generate a getter/setter method for the instance variable you choose. Assume that I have a java bean for a student (StudentBean).
If I'm going to write a get/set method for each variable I'll have to write 6 methods in total. Let Eclipse to this job.
Then choose the fields.

You can choose the insertion point of the automatically generated methods, their order and their access modifiers. My new StudentBean is now like this:
public class StudentBean {
private int studentId;
private String name;
private float gpa;
}
If I'm going to write a get/set method for each variable I'll have to write 6 methods in total. Let Eclipse to this job.
Source > Generate Getters and Setters
Then choose the fields.

You can choose the insertion point of the automatically generated methods, their order and their access modifiers. My new StudentBean is now like this:
public class StudentBean {
private int studentId;
private String name;
private float gpa;
public int getStudentId() {
return studentId;
}
public String getName() {
return name;
}
public float getGpa() {
return gpa;
}
public void setStudentId(int studentId) {
this.studentId = studentId;
}
public void setName(String name) {
this.name = name;
}
public void setGpa(float gpa) {
this.gpa = gpa;
}
}
at
14:24
Wednesday, March 18, 2009
ibm is planning to buy sun
Although there's no official statement on the matter, world street journal informs us of the possibility that IBM is planning on buying Sun. I wonder what will happen to Netbeans if that transaction takes place. Even though I largely choose Eclipse over Netbeans, it won't be cool to lose that IDE. I still think that Netbeans is better than Eclipse for web development on Java.
Friday, March 6, 2009
top 16 useful shortcuts in eclipse
Code of Doom presents the most useful Eclipse shortcuts. If you're using Eclipse for sometime you'll know some of them for sure, but there could be some shortcuts you missed. Check it!
Thursday, March 5, 2009
an eclipse summit in istanbul? here comes eclipsist!
Friday, December 5, 2008
javascript plug-in for eclipse
My favorite IDE for Java is Eclipse. So when I searched for a development environment for javascript, I checked if there's a javascript plug-in for Eclipse and the answer is yes. The installation is a piece of cake:
- Eclipse > Help > Software Updates > Available Software
- Type javascript in the search area
- Tick the checkbox next to "Javascript Developer Tools" with latest version
- Click Install
Subscribe to:
Posts (Atom)
