java

Set BufferedImage alpha mask in Java

I have two BufferedImages I loaded in from pngs. The first contains an image, the second an alpha mask for the image. I want to create a combined image from the two, by applying the alpha mask. My google-fu fails me. I know how to load/save the images, I just need the bit where I go from two BufferedImages to one BufferedImage with the...

Hot Deploy a Java EAR to Minimize or Eliminate Downtime of an Application on a Server?

I have heard that this is what JavaRebel does but is there any other good way to deploy a new version of an EAR while allowing users to remain active on the previous version? We use JBoss for the application server... ...

Java extendable enumeration

Is there a way to write an enumeration that can be extended. I have several methods that I would like to alway have available for my enumerations. For example I use an enumeration for my database fields. I include the actual field name in the database. public enum ORDERFIELDS { OrderID("Order_ID"); private String...

javafx on client side

Do the clients need something else than a proper jdk and javafx compliant browser to visit javafx applets? ...

Returning a gif image from a method

I am creating an application in java which will be the part of an external application. My application contains a viewport which shows some polygons and stuff like that. The external application needs to get the image of the viewport in gif format. For that it calls a method in an interface (implemented by my application) and my applicat...

what is JMS good for?

Hi, I'm looking for (simple) examples of problems for which JMS is a good solution, and also reasons why JMS is a good solution in these cases. In the past I've simply used the database as a means of passing messages from A to B when the message cannot necessarily be processed by B immediately. A hypothetical example of such a system i...

How to use MySQL prepared statement caching?

How do i take advantage of MySQL's ability to cache prepared statements? One reason to use prepared statements is that there is no need to send the prepared statement itself multiple times if the same prepared statement is to be used again. Class.forName("com.mysql.jdbc.Driver"); Connection conn = DriverManager.getConnection("jdbc:mysq...

How to expose an EJB as a webservice that will later let me keep client compatibility when ejb changes ?

Lots of frameworks let me expose an ejb as a webservice. But then 2 months after publishing the initial service I need to change the ejb or any part of its interface. I still have clients that need to access the old interface, so I obviously need to have 2 webservices with different signatures. Anyone have any suggestions on how I can...

Getting the Java thread id and stack trace of run-away Java thread

On my busiest production installation, on occasion I get a single thread that seems to get stuck in an infinite loop. I've not managed to figure out who is the culprit, after much research and debugging, but it seems like it should be possible. Here are the gory details: Current debugging notes: 1) ps -eL 18975 shows me the the Linux...

How to check JRE version prior to launch?

What's the best way to determine if the version of the JRE installed on a machine is high enough for the application which the user wants to run? Is there a way of doing it using java-only stuff? I'd like the solution to work on Windows/Linux/MacOSX - if the JRE version is too low a message should be displayed. Currently I'm getting an e...

Managing constructors with many parameters in Java 1.4

In some of our projects, there's an class hierarchy that adds more parameters as it goes down the chain. At the bottom, some of the classes can have up to 30 parameters, 28 of which are just being passed into the super constructor. I'll acknowledge that using automated DI through something like Guice would be nice, but because of some t...

Is there a good date parser for Java?

Does anyone know a good date parser for different languages/locales. The built-in parser of Java (SimpleDateFormat) is very strict. It should complete missing parts with the current date. For example if I do not enter the year (only day and month) then the current year should be used. if the year is 08 then it should not parse 0008...

Generating ActionScript value objects from middle-tier Java classes

In a Flex / Java app stack using remoting (via BlazeDS), classes to hold data passed back and forth between client and server need to be maintained in both the client (in ActionScript) and server (in Java). I want a way to maintain theses classes in Java only, and have the corresponding ActionScript value object classes generated by the...

Castor performance issues

We recently upgraded to Castor 1.2 from version 0.9.5.3 and we've noticed a dramatic drop in performance when calling unmarshal on XML. We're unmarshaling to java classes that were generated by castor in both cases. For comparison, using identical XML the time for the XML unmarshal call used to take about 10-20ms and now takes about 23...

How to stop Hibernate from eagerly fetching many-to-one associated object

I have a property on a domain object that is declared in a many-to-one element. The basic syntax of this property looks like this: <many-to-one name="propertyName" class="propertyClass" fetch="select" not-found="ignore" lazy="proxy" /> Now, the idea is to have Hibernate NOT eagerly fetch this property. It may be null, so the not-fou...

Is it possible with Java to delete to the Recycle Bin?

Java is the key here. I need to be able to delete files but users expect to be able to "undelete" from the recycle bin. As far as I can tell this isn't possible. Anyone know otherwise? ...

What is the best way to read, represent and render map data?

I am interested in writing a simplistic navigation application as a pet project. After searching around for free map-data I have settled on the US Census Bureau TIGER 2007 Line/Shapefile map data. The data is split up into zip files for individual counties and I've downloaded a single counties map-data for my area. What would be the b...

How Do You Get the Height of the Titlebar Using Java (Swing)?

I am getting a MouseEvent in Java. the getPoint() method is adding the height of the title bar into the y portion of the coordinate. I was wondering how I can find the height of the title bar of the current window in order to offset the y value by the correct amount. ...

Is there a type-safe Java implementation of 'reduce'?

I often need to run reduce (also called foldl / foldr, depending on your contexts) in java to aggregate elements of an Itterable. Reduce takes a collection/iterable/etc, a function of two parameters, and an optional start value (depending on the implementation details). The function is successively applied to an element of the collec...

Customizing java.text formatters for different Locales

Building a java application that supports different Locales, but would like to customize the DateFormat display beyond what is available between FULL,LONG,MEDIUM, and SHORT DateFormat options. Would like to do things like place a character between the date and time components of a DateFormat.getDateTimeFormat(), lowercase the AM/PM, etc...