lundi 22 juillet 2013

There are no resources that can be added or removed from the server

Some time would like to deploy an ear file to WAS (Web Application Server) as usual. But Eclipse fail to find your EAR and it show an alert like this :

 There are no resources that can be added or removed from the server   

the solution is that your project needs to have a Eclipse Dynamic Web Module facet. 

  1. right click on project and click properties
  2. Go to Project Facet and Select dynamic web module and click apply.
  3. go to tomcat and click add/remove

How to fix GC overhead limit exceeded in Eclipse


Eclipse will throw GC overhead limit exceeded error when it runs out of memory, normally while performing memory-consuming operations such as building workspace on big projects.

 An internal error occurred during: "Building workspace". GC overhead limit exceeded  
To fix this problem, you'll need to allocate more memory to your Eclipse instance. To do this, go to the Eclipse installation directory, and locate the eclipse.ini file.
To increase the memory allocation for your Eclipse instance, edit the number in the following lines accordingly.
 -Xms1024m   
 -Xmx2048m  
The number is the amount of memory, in Megabytes.
You can also increase the value of MaxPermSize, as the following:
 -XX:MaxPermSize=1024m  

Restart Eclipse for the changes to take effect.

lundi 8 juillet 2013

Comment afficher une Valeur double avec 2 chiffres aprés la Virgule ?


La classe java.text.DecimalFormat permet de formater une valeur numérique dans le format de son choix en utilisant un pattern dont les symboles principaux sont les suivants :
  • 0 permet de représenter un chiffre qui devra obligatoirement être présent, même s'il s'agit d'un zéro inutile.
  • # permet de représenter un chiffre en ignorant les zéros inutiles.
  • . (le point) permet de représenter le séparateur de la partie décimale.
  • , (la virgule) permet de représenter le séparateur des groupes (milliers, millions, etc.).

(vous pouvez vous reporter à la documentation de la classe DecimalFormat pour obtenir la liste complète de tous les symboles).
Format 0 0,02 0,8 12,9
# 0 0 1 13
### 0 0 1 13
0 0 0 1 13
000 000 000 001 013
#.## 0 0,02 0,8 12,9
0.## 0 0,02 0,8 12,9
0.00 0,00 0,02 0,80 12,90
#.00 ,00 ,02 ,80 12,90
#,##0.00 0,00 0,02 0,80 12,90

par exemple :
double ma_Valeur ;
DecimalFormat df = new DecimalFormat("#.##");
System.out.println(df.format(ma_Valeur));

mercredi 3 juillet 2013

Restore Deleted Files using Git


Sometime you can delete a file  ,by accident, and then you commit your changes . after a while you recognize that you need this file So what you can do ??
what I have tried to resolve such problem (there are several ways) is  this few steps :
  1. List all files that have been deleted from my git repository :
    git log --diff-filter=D --summary
    
    
  2. Search the commit where you deleted your file
  3. undo your commit to the searched one BUT don't lose your modifications by taping this cmd :
    git reset --soft HEAD~n   
    

    n: is the number of undo commit steps

  4. if you type  git status  you will re-view your deleted file so to get the file back type this cmd :
    git checkout -- [file name]
    
Hope this could helps someone :D