java

Horrendous Performance in a Simple Java2D App

Hi all, I've just finished my entry for the 14th Ludum Dare 48-hours game making competition yesterday, and decided to do it in java using java2d for the graphics. I'm not that familiar with the API and haven't done a lot of graphics programming, but my game is quite small (only a dozen or so very small moving object) so I assumed I c...

What is the best explanation for the term "generic"?

I am looking for an good explanation, maybe with some examples. In my understanding, something is "generic" when it can be used for multiple purposes. But I may be wrong... ...

ORA-01654: unable to extend index

Calling all Oracle Gurus! I am in the process of clustering a well tested application on WebSphere. The application in question made it about half way through processing 1k of JMS messages from a queue before this happened. ---- Begin backtrace for Nested Throwables java.sql.SQLException: ORA-01654: unable to extend index DABUAT.INDEX1...

Running 2 threads simultaneously

In the case of an IM client. I have made 2 separate threads to handle sending packets (by std io) and receiving packets. The question is how to make these 2 threads run simultaneously so that I can keep prompting for input while at the same time be ready to receive packets at any time? I have already tried setting a timer but the data...

JPOX JDO and Castor JDO compared to Hibernate persistence

Do these frameworks (JPOX JDO and Cater JDO) work off similar principles as Hibernate? Do they use configuration data plus a combination of reflection and generics? What are some of the major architectural differences? ...

How can I best initialize constants from a database or servlet context?

We have constants declared in an interface in our application like this. public interface IConstants { public static final String FEVER="6"; public static final String HEADACHE="8"; } We now want to populate these constants values (6 and 8) from the database (or application servlet context). The database values stored in a lo...

Lazily Initialization of a Collection

What's the best way to lazily initialize a collection, I'm specifically looking at Java. I've seen some people decide to do this in modification methods (which seems a bit yucky), as follows: public void addApple(final Apple apple) { if (this.apples == null) { apples = new LinkedList<Apple>(); } this.apples....

JAVA: Why does this not get garbage collected?

Hi all, Quick question about the theory of GCing. I have the following method. It runs, and exits the method. How come even after GC is run, the timer still exists and keeps "TICK"ing? I don't believe there's still a reference to timer or the timertask anymore after this method exists, so I'd expect the timer to be GCed and cause an...

Is there a parameter I can use in Java that works with all for-each loops?

Suppose I've got a method that accepts an array and processes each element in it using Java's built in for-each loop, like this: public static void myFun(SomeClass[] arr) { for (SomeClass sc : arr) { // Stuff is processed here } } This works just fine, but now I want to be able to pass the same method a List<SomeClass>...

speech recognition in java

Hi I want to use speech recognition in my project and I found this code but when I run it I get an error which is rec is null java.lang.NullPointerException at newpackage.HelloWorld.main(HelloWorld.java:55) please could one of you help me in this problem or if you have other code could you send it to me. This of server code that I u...

Java: using WritableRaster.setRect to superimpose an image?

I have been playing with some of the imaging functionality in Java, trying to superimpose one image over another. Like so: BufferedImage background = javax.imageio.ImageIO.read( new ByteArrayInputStream(getDataFromUrl( "http://www.google.com/intl/en_ALL/images/logo.gif" )) ); BufferedImage foreground = javax.imageio.Ima...

Android MANIFEST.MF equivalent

On normal JVMs you can use META-INF/MANIFEST.MF to declare application properties, in J2ME you can use the .jad-Files but what can you do on Android? I need a way to declare properties which I can access using System.getProperties() on Android. It would be best if I could use the same file format as MANIFEST.MF-like property files use. ...

jdbc performance testing for getting CLOB/BLOB data

I am trying to compare the performance of the different calls (getBytes/getBinary/getBlob) for getting data out of a BLOB column. What I am doing right now is tracking the time to execute the statement via the jdbc driver and iterating through the resultset. //Mark time ResultSet resultSet = stmt.executeQuery(query); resultSet.getByte...

Where to put DTD and schema files

I have a fairly typical JavaEE application, composed using EJB3, seam components, spring beans and JSF, all packaged into several jar and war files inside an ear file. Naturally for JavaEE, we have many XML files as part of the application. Some of these XML files are validated using DTD (seam) and some using schema. As most files where...

Adding an ArrayList into a class - what does it do?

Hi Following on from this Q of mine: http://stackoverflow.com/questions/754184/whats-the-best-way-to-make-this-java-program I was recommended to store a list in Lecturer class and Course class. So I did, and it looks something like this: public class Lecturer { private String id; private String name; List<Course> cours...

Why doesn't java.util.Set have get(int index)?

I'm sure there's a good reason, but could someone please explain why the java.util.Set interface lacks get(int Index), or any similar get() method? It seems that sets are great for putting things into, but I can't find an elegant way of retrieving a single item from it. If I know I want the first item, I can use set.iterator().next(), ...

Asynchronous web service streaming

I need some framework that will help me to do asynchronous streaming over http. It may look like SOAP WS or somethign else. I don't know if I name it correctly, so here is what I need: ServerA wants to make a request to remote ServerB over http. The request contains arbitrary information. Result for it is going to contain multiple recor...

Replacing BrowserLauncher with BrowserLauncher2

I am starting on an enhancement to an existing Java applet where I let the user hit a link in a menu item, and open a page in his/her default browser. Some of our deployed code is in Java 1.4, while the majority of it is in Java 5. This prevents me from using the Desktop API in Java 6. It looks like the easiest way to solve the problem i...

Java's L number (long) specification question

Hi all, It appears that when you type in a number in java, the compiler automatically reads it as an integer, which is why when you type in (long) 6000000000 (not in Integer's range) it will complain that 6000000000 is not an integer. To make it shut up, I had to specify 6000000000L. I just learned about this specification. Are there...

How to start Java from within a C process?

I want to add some Java (actually Clojure) based event handlers to a HUGE legacy C application. What is the most straight forward and easily maintained way to do this? I would like the Java classes to be running in the same process as the C code. Is this even possible? ...