Wednesday, 15 July 2015

Eclipse Code Template


I came across importing same stuff frequently. I thought of creating the shortcut for this.
Then I found eclipse is good in providing this kind of stuff.

The stuff  I want to import are Logger from SLF4J, for this we have to import slf4j and lo4j api in our class.Which is irritating stuff to type everytime while creating new class.

Eclipse already have code templates which some of them are shown below:










Now we will  create a code template which will show as above

Solution:

Window->Preferences->Java -> Editor -> Templates
 
 
you Will see below :






Click on "New" 



Enter template Name as "slf4j" 
Write description
Add Patteren given below in the box.

Click OK.


For SLF4J:

${:import(org.slf4j.Logger,org.slf4j.LoggerFactory,org.slf4j.Logger,org.slf4j.Logger)}
private static final Logger LOGGER = LoggerFactory.getLogger(${enclosing_type}.class);


For Log4J:

${:import(org.apache.log4j.Logger)}
private static final Logger LOG = Logger.getLogger(${enclosing_type}.class);



Now you will see the slf4j code template in your eclipse .
 Start Typing sl and CTRL+SPACE. you will...like this..:-)





























Wednesday, 29 October 2014

Java SecurityException : signer information does not match



Java SecurityException : signer information does not match



Cause :
It is happening due to loading of same jar  with multiple versions .

Example :
 In one of my case I faced the same issue.  I have "httpclient-4.1.2.jar" and "httpclient-4.0.jar" jars in my lib folder . Due to this , while loading the jar files , http client is verifying the signature signed by apache. It is getting error due to different certificates from two jar files.


Solution:
 Just remove the one of the jar , in my case I removed old version jar.