My team is researching dependency injection frameworks and is trying to decide between using Google-Guice and PicoContainer. We are looking for several things in our framework: A small code footprint – What I mean by a small code footprint is we don’t want to have dependency injection code litter …
Why does my icon handling code throw a NullPointerException?
I have added an image for my button,but when I run that frame this exception will be thrown .why?please help me. line 138: line91: I use this poor checking (Peter Lang recommended)which is:System.out.println(getClass().getResource(“/Images/yahoo_1.gif”)); and it returns null,why? please help me. A…
Does Java have the ‘@’ character to escape string quotes?
My string has double quotes in it, in C# I would do: string blah = @”this is my “”text”; how would I do that in Java?
increasing heap size in netbeans.conf file
I was reading in netbeans 6, you don’t have to set the maximum heap size, it will just look at your computer for that information. My system has 8 gigs of ram, but my application only has 64mb to play with and it is running out of memory. I did a: System.out.println(Runtime.getRuntime().maxMemory()); An…
Using Command Design pattern
Can anyone explain with a simple example the Command Pattern? I tried searching on the internet, but I got confused. Answer For the most part, commands are immutable and contain instructions that encapsulate a single action that is executed on demand. You might also have a RuntimeCommand that accepts instruct…
JPA OneToMany not deleting child
I have a problem with a simple @OneToMany mapping between a parent and a child entity. All works well, only that child records are not deleted when I remove them from the collection. The parent: The child: If I now delete and child from the childs Set, it does not get deleted from the database. I tried nullif…
How to get the current date and time
How do I get the current date and time in Java? I am looking for something that is equivalent to DateTime.Now from C#.
Download and open PDF file using Ajax
I have an action class that generates a PDF. The contentType is set appropriately. I call this action through an Ajax call. I don’t know the way to deliver this stream to browser. I tried a few things but nothing worked. The above gives the error: Your browser sent a request that this server could not u…
Check if int is between two numbers
Why can’t do you this if you try to find out whether an int is between to numbers: Instead of it, you’ll have to do which seems like a bit of overhead. Answer One problem is that a ternary relational construct would introduce serious parser problems: When you try to express a grammar with those pr…
Java inverse matrix calculation
I’m trying to calculate the inverse matrix in Java. I’m following the adjoint method (first calculation of the adjoint matrix, then transpose this matrix and finally, multiply it for the inverse of the value of the determinant). It works when the matrix is not too big. I’ve checked that for …