java

Java, Call overridden method implicitly

Right now in some Java code I have something like this class A { void f() { } A() { f(); } } class B extends A{ @Override void f() { //do some stuff super.f(); } } class C extends B { @Override void f() { //do some stuff super.f(); } } I want to have f() called and then iterate upwards through each parent class,...

How to use java interfaces with multiple implementing classes.

public interface Foo { } public class SpecificFoo implements Foo { } public interface SomeInterface { void thisMethod(Foo someKindOfFoo); } public class SomeClass implements SomeInterface { public void thisMethod(Foo someKindOfFoo) { // calling code goes into this function System.out.println("Dont go here please"); } public...

JMS client does not receive messages

I am using Glassfish JMS. I am able to add messages to a queue. I can see the messages using the QueueBrowser object. However the MessageConsumer (nor the QueueReceiver) cannot receice any message and return null. Message expiration is set to 0 and I remember to open the connection. Any ideas? Here is the code: Session session ...

Error-tolerant XML parsing in Scala

I would like to be able to parse XML that isn't necessarily well-formed. I'd be looking for a fuzzy rather than a strict parser, able to recover from badly nested tags, for example. I could write my own but it's worth asking here first. Update: What I'm trying to do is extract links and other info from HTML. In the case of well-formed ...

Sending a large request to a service in smaller batches (Java)

I work with a large Java web application which uses a service to return information. My key goal is to retrieve 100+ individual results as quick as possible. We've noticed that sending 100+ requests for information doesn't give us the best performance on the replies of data. Our solution was to break the 100+ requests into small batch...

Has anyone ever read the Java Language Specification(JLS)?

I recently had a question about String and String interning - pretty simple question which I got a quick answer to. But lo and behold I got a detailed answer to that same question on pg. 29 of the JLS 3rd Edition. It's really interesting that a lot of the questions we asked are answered in the JLS but its such a boring 600 page read (the...

Current position of Java Language Conversion Assistant and J#

A recent answer to a question on converting Java to C# suggested I should use Java Language Conversion Assistant and pointed to: http://msdn.microsoft.com/en-us/library/7tatw8a2%28VS.80%29.aspx I cannot find JLCA on my Visual Studio (9.0.30729.1) and on looking at Wikipedia (http://en.wikipedia.org/wiki/J%5FSharp) I find: Retiremen...

JFreeChart get mouse coordinates

Is there a way in JFreeChart to determine from a ChartMouseEvent that x,y coordinates (in plot space) the mouse is over? I've tried using the domain crosshair value but that seems inaccurate and lags the actual mouse event. thanks, Jeff ...

Code using classes and interfaces

I'm new to Java, but I understand the basics. I know that interfaces are abstract classes and they're used for emulating multiple inheritance (kind of - I know that in Java this is not allowed). I have this code; would you explain it to me? Here is part of a method that iterates over a list of classes: Constructor[] c = aClass.getConst...

Modify Http response

Hi, I have a need to write a Servlet filter to inspect the HTML being sent out and modify all the links that point to /images in it to a different domain altogether so that they are served from a CDN(content delivery network) rather than my site. Is this recommended and how can I achieve this? -thanks ...

Java 2D ArrayList and sorting

I need to sort a shopping list by the aisle the item is located for example: [Bread] [1] [Milk] [2] [Cereal] [3] I am planning to do this with ArrayList and was wondering how to make an 2D ArrayList Bonus questions: any ideas on how to sort by the aisle number? ...

Wicket Dynamic Image URL

Short question: I need to turn a dynamic image pulled from a database into a URL without adding a component to the displaying page (such as using a NonCachingImage) using Wicket. The perfect solution (that I've implemented in other Frameworks) is simply to create a page that takes the image ID as a url parameter and renders the image to...

JVM crash on opening a "return" SocketChannel

Hi Was working my ... off on a handin project this evening, and suddenly the JVM started crashing on me. I've been able to create a simple program that can reproduce the crash, and have submitted it to Sun, but I wondered if anyone in here could take a look at the program, and tell me if I'm doing something stupid (ie there's an easy wa...

Easy way to compare ArrayLists for equality using JUnit?

What is an easy way to compare ArrayLists for equality using JUnit? Do I neeeeeed to implement the equality interface? Or is there a simple JUnit method that makes it easier? ...

Help with Java Calendar -- it is giving some strange output

Hi, I'm newish to Java and am trying to do somethings with dates. First I started using the Date class, which I found out was mostly deprecated so I switched over to Calendar. Now I am getting weird values. for example the Month value for December is 0, not 12. And on those Calendars where it is giving me 0 for December it is also...

how to create installer using installjammer

Hi I have created a java application. which depends on some external jars also. Now i want to create installer for my application and I have installjammer tool. So how to create installer for windows platform using installjammer. Thanks Sunil Kumar Sahoo ...

Add text and icon (with MouseListener) to JTable column

Hi I want to implement following functionality but I am confused if it's possible in Java. If yes, than how? Please help: I want to create a JTable kind of table where 1st row of table contains column names and an icon in each column i.e. in each cell of 1st row. Clicking on that icon should lead to removal of that column from table (...

JSF, writeAttribute("value", str, null) fails with strings obtained through ValueExpression.getValue()

Hello, I'm having a somewhat weird problem with custom JSF component. Here's my renderer code: public class Test extends Renderer { public void encodeBegin(final FacesContext context, final UIComponent component) throws IOException { ResponseWriter writer = context.getResponseWriter(); write...

Depending on com.sun.javadoc from tools.jar (Sun JDK) in Eclipse

One of our plugins requires an installed JDK, not just an JRE. We need com.sun.javadoc and friends from tools.jar. I do not think Sun's license will allow redistributing tools.jar (which is not necessary if you already have a JDK anyway). It also seems there is no way in Eclipse to specify a JDK as a dependency. All answers in the Eclip...

Java Puzzler - Can anyone explain this behavior ?

abstract class AbstractBase { abstract void print(); AbstractBase() { // Note that this call will get mapped to the most derived class's method print(); } } class DerivedClass extends AbstractBase { int value = 1; @Override void print() { System.out.println("Value in DerivedClass: " + va...