java

Java: notify() vs. notifyAll() all over again

If one google for "difference between notify() and notifyAll()" then a lot of explanations will pop up (leaving apart the javadoc paragraphs). It all boils down to the number of waiting threads being waken up: one in notify() and all in notifyAll(). However (if I do understand the difference between these methods right), only one thread...

Exposing a remote interface or object model.

I have a question on the best way of exposing an asynchronous remote interface. The conditions are as follows: The protocol is asynchronous A third party can modify the data at any time The command round-trip can be significant The model should be well suited for UI interaction The protocol supports queries over certain objects, and s...

How can an application utilize multiple cores or CPUs in .NET or Java?

When launching a thread or a process in .NET or Java, is there a way to choose which processor or core it is launched on? How does the shared memory model work in such cases? ...

What is the best way to get OS specific information in Java?

Specifically getting on Windows the "..\Documents & Settings\All Users, basicaly any path that needs the front end to be dynamically derived based on the OS your software is running on. (Now I need the answer to this) the current users My Documents dirctory (okay this has been answered) and basicaly any path that needs the front end t...

What's the best way to persist data in a Java Desktop Application?

I have a large tree of Java Objects in my Desktop Application and am trying to decide on the best way of persisting them as a file to the file system. Some thoughts I've had were: Roll my own serializer using DataOutputStream: This would give me the greatest control of what was in the file, but at the cost of micromanaging it. Straig...

Checking the results of a Factory in a unit test

I have developed some classes with similar behavior, they all implement the same interface. I implemented a factory that creates the appropriate object and returns the interface. I am writing a unit test for the factory. All you get back is an interface to the object. What is the best way to test that the factory has worked correctly?...

How to deal with "java.lang.OutOfMemoryError: Java heap space" error (64MB heap size)

I am writing a client-side Swing application (graphical font designer) on Java 5. Recently, I am running into "java.lang.OutOfMemoryError: Java heap space" error because I am not being conservative on memory usage. The user can open unlimited number of files, and the program keeps the opened objects in the memory. After a quick research ...

Equivalent to StAX for C

I've used the StAX API in Java quite a bit, and find it quite a clean way of dealing with XML files. Is there any equivalent library I could use for performing similar processing in C? ...

Multiple threads stuck in native calls (Java)

I have a problem with an application running on Fedora Core 6 with JDK 1.5.0_08. After some amount of uptime (usually some days) threads begin getting stuck in native methods. The threads are locked in something like this: "pool-2-thread-2571" prio=1 tid=0x08dd0b28 nid=0x319e waiting for monitor entry [0xb91fe000..0xb91ff7d4] at java....

What is reflection, and why is it useful?

What is reflection, and why is it useful? I'm particularly interested in Java, but I assume the principles are the same in any language(?). ...

Eclipse Plugin Dev: How do I get the paths for the currently selected project?

I'm writing a plugin that will parse a bunch of files in a project. But for the moment I'm stuck searching through the Eclipse API for answers. The plugin works like this: Whenever I open a source file I let the plugin parse the source's corresponding build file (this could be further developed with caching the parse result). Getting th...

How do you use WebServiceMessageDrivenBean in Spring-WS?

How do you use the the org.springframework.ws.transport.jms.WebServiceMessageDrivenBean class from the Java Spring Framework - Spring-WS project? There is very little documentation or examples available on the web. ...

How to test java application for performance bottlenecks?

I am reviewing a big java application to see if there are any performance bottlenecks. The real problem is that I cannot pinpoint the performance issues to any single module. The whole application is slow as such. Is there some tool/technique I can use to help me out in this? ...

How do I change XML indentation in IntelliJ IDEA?

By default IntelliJ IDEA 7.0.4 seems to use 4 spaces for indentation in XML files. The project I'm working on uses 2 spaces as indentation in all it's XML. Is there a way to configure the indentation in IntelliJ's editor? ...

Why @OneToMany does not work with inheritance in Hibernate

@Entity @Inheritance(strategy = InheritanceType.SINGLE_TABLE) public class Problem { @ManyToOne private Person person; } @Entity @DiscriminatorValue("UP") public class UglyProblem extends Problem {} @Entity public class Person { @OneToMany(mappedBy="person") private List< UglyProblem > problems; } I think it is pretty...

Generics in Java

Is there any shorthand way of defining and using generic definations without having to keep repeating a particular generic description such that if there is a change I don't have to change all definations/usages though out the codebase for example is somethhing like this possible: Typedef myGenDef = < Object1, Object2 >; HashMap< myGen...

Any data-driven open source JEE5 EJB3+JSF Sample Project out there?

I am looking for an open source project that uses EJB3 as backend and JSF as frontend. It should not be a tutorial but a real application that real people are using. The application should be data-driven, i.e. the following aspects are fundamental and make 80% or more of the application. form-based (many input forms) table views, mast...

What lightweight neural networks are there for Java?

I have a specific problem of having to decide in a fuzzy way between various outputs from a given set of metrics. It's a perfect candidate for neural network approaches. I've used Joone in the past with success but I'm a little scared of its 2MB jar file for something that in my mind can be done in far less code than that. Of course t...

How do I strip the fluff out of a third party library?

It may not be best practice but are there ways of removing unsused classes from a third party's jar files. Something that looks at the way in which my classes are using the library and does some kind of coverage analysis, then spits out another jar with all of the untouched classes removed. Obviously there are issues with this. Specif...

Manipulating content of pages that pass through an HTTP proxy (and calling Java)

I need to make a web proxy that adds annotations to the HTML of web pages that pass through. I'm hoping some decent software exists that can handle the HTTP proxying part of the application, so that, for the most part, I only have to worry about making a function that sits on the stream with a signature similar in intent to void proces...