java

EJB3 constructor throwing an exception?

What happens, if an EJB3 stateless/stateful bean no args constructor throws an exception? For example, class A has a DI: @EJB B b; and B throws an exception in the constructor? I didn't find any mention for this case in EJB3 specs. I'd guess that the isntance of class A gets discarded, because it really has no means for succeeding in ...

Is there a good url builder for Java?

Is there a good url builder for java? ...

Tool for importing Excel spreadsheets

Hi, I need to import some Excel spreadsheets into Java objects. I will use POI to do the task (an old version of it unfortunately). However I wonder if there is some high-level framework to do the same task but declaratively. I'm thinking in Castor and XML. The mapping Excel-Class will be stored in a resource (e.g. an XML file). Yes, I'...

BIRT: Java - eventhandler, loaction of the files

Hello! I want to implement eventhandling for my reports via java-classes... where do i have to put the files? And do i need .class-files or .jar-files? BIRT 2.1.3, RCP - Designer ...

Java, Don't wait for a thread to complete

I need to find a way to spin off a thread from a static call and not wait for the thread to complete. Basically, a "fire and forget" approach. Can someone supply me with a simple example of how this can be accomplished? ...

send real time voice using udp

hi every body could you please help me . I write java code for sending string msg between client and server using udp socket . but I want to to send real time voice so could you please give some notes to do it ...

Smart quotes in a MimeMessage not showing up correctly in Outlook

Our application takes text from a web form and sends it via email to an appropriate user. However, when someone copy/pastes in the infamous "smart quotes" or other special characters from Word, things get hairy. The user types in he said “hello” to me—isn’t that nice? But when the message appears in Outlook 2003, it comes out l...

Can you use Future/Futuretask objects with Spring TaskExecutors?

Is it possible to use Java FutureTask with a Spring TaskExecutor to get a Future object? I'm looking for a TaskExecutor that implements the Java ExecutorService interface, in particular the submit() method. Looking through the Spring Javadocs doesn't reveal any classes like this. Is there some alternate method to handle futures through...

How to manage java ee transactions?

I'm currently using Java EE to inject my EntityManager into a web app as follows: @PersistenceContext EntityManager em; @Resource UserTransaction utx; I have this in a request scoped JSF bean. It works, but it's a pain because to avoid the NoTransactionException I have to wrap every DAO method like so: public void saveSomething(Obj ...

What is the best practice for reading property files in J2EE?

I have several J2EE web applications running inside the same application server and I wanted to externalize the properties files that are inside the jars to a new directory to make these properties visible. What is the recommended way to load these properties files? Thanks. ...

CodeReview: java Dates diff (in day resolution)

Hello folks, Please your opinion on the following code. I need to calculate the diff in days between 2 Date objects. It is assured that both Date objects are within the same TimeZone. public class DateUtils { public final static long DAY_TIME_IN_MILLIS = 24 * 60 * 60 * 1000; /** * Compare between 2 dates in day resolution. * * @r...

Calling Snarl from java code

Hi, Does anyone know how to call snarl api from java code? Thanks ...

Dead Lock Thread Check

Hi Experts, Can somebody tell me how can I find out "how many threads are in deadlock condition" in Java multi-threading application? What is the way to find out the list of deaklock threads? I heard about Thread Dump and Stack Traces but I don't know how to implement it. I also want to know what all new features have been introduced...

Overcoming heap overflow issues

After taking a single Computer Science course last semester, I've been attempting to improve my coding abilities by trying to solve problems from Project Euler. I know my method would work logically(it returns answers to the small scale problem almost instantly). However, it scales horribly. If anyone could help me develop a better appro...

Java appending XML docs to existing docs.

I have two XML docs that I've created and I want to combine these two inside of a new envelope. So I have <alert-set> <warning>National Weather Service...</warning> <start-date>5/19/2009</start-date> <end-date>5/19/2009</end-date> </alert-set> and <weather-set> <chance-of-rain type="percent">31</chance-of-rain> <conditi...

Best way to close nested streams in Java?

What is considered the best, most comprehensive way to close nested streams in Java? For example, consider the setup: FileOutputStream fos = new FileOutputStream(...) BufferedOS bos = new BufferedOS(fos); ObjectOutputStream oos = new ObjectOutputStream(bos); I understand the close operation needs to be insured (probably by using a fin...

Range Slider in Java

Hi i was wondering if any has heard of a Java component that provides a range slider. A slider, that is, with two knobs that define a range in the min max values rather than just one. I found on the web a JRangeSlider in the perfuse library but i have two issues with it. First (and not that important) is that it has it's own visual sty...

Hibernate using an instance of javax.sql.DataSource

Is it possible to configure Hibernate to use a javax.sql.DataSource instance? My application already has an instance of javax.sql.DataSource and I'd rather not re-configure the database url, user, password, driver etc just for hibernate. ...

Is there an idiom in Java for empty methods which exist to satisfy an interface?

Let's say I have a class Foo implementing an interface such as MouseListener. The MouseListener interface consists of five methods but I only wish to override one of them (mouseClicked()). Is there a standard, idiomatic way of formatting the other methods? My inclination was to write the following: @Override public void mouseClicked(...

Ouput XML with Freemarker

We are using freemarker for templates in our web application. We are using spring's FreeMarkerViewResolver for this. Is there a way in freemarker to change the content type on the response to text/xml is there a way to do this in the template? ...