I have a 35×40 px. png image I want to use as a custom cursor in a Swing application. The image has a glow so contains alpha transparency values. Problem is when I attempt to use the conventional method of using the Toolkit to generate the custom cursor I get black pixels where alpha transparency values …
How to create Currency instance with non ISO 3166 country like en_UK?
In my app, I get the user’s default locale using Locale.getDefault() and then pass that to Currency.getInstance(Locale). It mostly works, but I have started getting reports from users which show the following IllegalArgumentException in the stack trace: Caused by: java.lang.IllegalArgumentException: Uns…
How to convert UTC time into local time in Java?
I have time coming from gpslocation service in 1352437114052 format. Can some one tell me how to convert this into local time either in Java or Matlab or Excel. Answer Create a new Date from your milliseconds since epoch. Then use a DateFormat to format it in your desired timezone.
How to Send bulk mails using javax.mail API efficiently? & Can we use reuse authenticated sessions to improve speed?
I am able to send a mail using javax.mail API. But the problem here is on an average for each mail it taking around 4.3 seconds to send to destination. If I am sending a 20 mails sequentially, it takes around 86.599 seconds. For my requirement this approach will not work. I am looking for an approach which ca…
Can not find the tag library descriptor for âhttp://java.sun.com/jsp/jstl/coreâ
I have included this at the very top of my JSP page: I already placed the JSTL JAR file in the WEB-INF/lib directory. But still, the JSP can’t resolve the taglib. I get the below error: Can not find the tag library descriptor for âhttp://java.sun.com/jsp/jstl/coreâ I am using Eclipse Juno and the pr…
Eclipse Java – invalid package name – Reserved words in package name
I am in the middle of an android project and was trying to create a new package in it. Well, Eclipse is not letting me to create it and is showing this error: Invalid package name. ‘new’ is not a valid Java identifier I never knew package name has reserved words, which we cannot use. My questions …
What do Bitset size() and length() mean, and what is the difference between them?
I don’t quite understand the different meanings of size() and length() in BitSet. Check the code below: Output is: I thought I would get something like Where do these trailing zeroes come from? Can someone explain this to me? thanks~~ Answer answer is quite simple the BitSet constructor just says it gen…
What are worker threads, and what is their role in the reactor pattern?
I’m trying to understand the Reactor pattern (concurrent), but in many examples they are talking about ‘worker threads’. What are worker threads? In what way do they differ from ‘normal’ threads? And what is their role in the reactor pattern? Answer The Reactor pattern is used wi…
How to disable @PostConstruct in Spring during Test
Within a Spring Component I have a @PostConstruct statement. Similar to below: During Unit tests I would not like to have the @PostConstruct function called, is there a way to telling Spring not to do post processing? Or is there a better Annotation for calling a initiation method on a class durning non-testi…
How to check if user defined entry in vector in java?
I have a vector of entries. Each entry is an instance of this class: The vector is declared as shown below: After that, the vector is populated. Then I want to check if certain key is somewhere in the vector. So I do this: This seems not to work. Why? How can I get it to work? P.S. CustomSet is