java

Eclipse: adding a whole repository for all projects to use

Hi, I have been working on Eclipse recently. I am fairly new to java programming, so this question might seem novice to some. I have been working on projects which have references to many other projects. So, when I create the project in my eclipse environment, it shows errors on many places, as I believe it is not able to pick-up all t...

Random crashes of Java VM in ConcurrentGCThread

We have problems with JVMs running internet applications under changing load. This problem comes and goes. One day we see three VMs dying and after that, there is nothing for a week or two. We have not found a pattern yet, found nothing to reproduce or cause it. Also a search in the Sun bug database did not help. We tried a suggested wo...

Two Way Mapping using single Data Structure

I ran across some code recently at work (recreated to be similar to what I am dealing with) similar to the code below Is there a way I can rework the code below to use one data structure (with performance in mind)? Here is some code to illustrate what I mean: public class ObjectMapper { private Map<UUID,Integer> uuidMap; pri...

Hibernate + Spring using multiple datasources?

I'm working on a web application that uses Spring MVC 2.5 and Hibernate. One of the requirements of the application is that it must be able to export some objects to an external database. I figure I might as well use my existing data layer and just save the objects to the external source. I'm new to Spring and Hibernate, and I guess I...

Are the Java Servlet APIs backwards compatible?

I want to write a JAR file that makes use of the javax servlet API. If I write against version 2.2, does that mean it will work on versions 2.3, 2.4 and 2.5? Thanks ...

Testing Spring MVC annotation mapppings

With Spring MVC, you can specify that a particular URL will handled by a particular method, and you can specify that particular parameters will map to particular arguments, like so: @Controller public class ImageController { @RequestMapping("/getImage") public String getImage( @RequestParam("imageId") int imageId, Map<String,Obje...

Java regex to match "t" except when it's "[t" or "t]"

I'm using replaceAll() on a string to replace any letter with "[two letters]". So xxxaxxx to xxx[ab]xxx. I don't want the ones that have already been replaced to be done again (turns to xxx[a[cb]]xxx)... An easy way to do this would be to exclude any letters that are proceded by a "[" or followed by "]". What's the correct Regex to use?...

A Java Plugin Framework that supports JARs

More specifically, is there any Java plugin frameworks have all of the below features: Support for multiple JAR files JARs can be signed and/or sealed Can perform a license check for each JAR prior to instantiation Can load multiple JARs using multiple threads ...

Java detection failing in Safari on Windows

I need to detect java version in browser, I have used deployJava.js file to detect java. I think there is definitely a problem , the way deloyJava.js ( java detection and deployment helper file from Sun) works with Safari on Windows. You can see the problem in action if you go to official java verification page (http://www.java.com:80/...

Why does the java.util.Set<V> interface not provide a get(Object o) method?

I understand that only one instance of any object according to .equals() is allowed in a Set and that you shouldn't "need to" get an object from the Set if you already have an equivalent object, but I would still like to have a .get() method that returns the actual instance of the object in the Set (or null) given an equivalent object as...

In Java, how do you determine if a thread is running?

How do you determine if a thread is running? ...

Why does Maven have such a bad rep?

There is a lot of talk on the internet about how Maven is bad. I have been using some features of Maven for a few years now and the most important benefit in my view is the dependency management. Maven documentation is less than adequate, but generally when I need to accomplish something I figure it out once and then it works (for exam...

Is the Java Virtual Machine really a virtual machine in the same sense as my VMWare or Parallels file?

Is the Java Virtual Machine really a virtual machine in the same sense as my VMWare or Parallels file? ...

URL to load resources from the classpath in Java

In Java, you can load all kinds of resources using the same API but with different URL protocols: file:///tmp.txt http://127.0.0.1:8080/a.properties jar:http://www.foo.com/bar/baz.jar!/COM/foo/Quux.class This nicely decouples the actual loading of the resource from the application that needs the resource, and since a URL is just a Str...

Google's AppEngine - java.nio.BufferOverflowException

I am playing with Google's AppEngine Java support. I have a fairly simple set of JSP pages, and was looking at the logs today, and saw that I was getting a BufferOverflowException from the following JSP file: <% response.sendRedirect("index.jsp"); %> I simplified the file to just this, and I still get the error. Any ideas? Here is th...

Web Service -Timeouts on the implementation side

Hi, I am calling a Web Service and i want it to respond within 5 seconds. If it can't process it in 5 secs (ignoring network latency) i want it rollback the transaction and send me a Timeout exception. I can see timeouts being set only on the Calling Client's code. I want this to be enforced by the Web Service Implementer (Server side)...

Preserving the size of a JButton in BorderLayout.CENTER

Is there a way of preserving the natural size of a JButton in the center of a BorderLayout? Right now, it expands in all directions to fill it up, but I want it normal size. If it isn't possible, how can I get a button to be in the center of a panel with its normal size? ...

Is the -Xdebug option supported in JDK 1.5?

I couldn't find any suitable documentation for the same. In any case, which is the best way to generate trace reports while running a JVM process (a tool provided by SUN in its JDK bundle preferably) so that any JVM crashes can be logged? Thanks in advance, z0ltan ...

Reading date values from excel cell using POI HSSF API

I'm using POI HSSF API for my excel manipulations in Java. I've a date value "8/1/2009" in one of my excel cell and while I try to read this value using HSSF API, it detects the cell type as Numeric and returns the 'Double' value of my date. See the sample code below: cell = row.getCell(); // date in the cell '8/1/2009' switch (cell.get...

Detect Mouse Move Event On JPanel

I have a JPanel, which I would like to detect the following events (1) When the mouse move in (2) When the mouse move out The (1) is quick easy. (2) is a bit tricky. Currently, I have to register event at all the components around JPanel. If the neighbor around JPanel detected a mouse move in event, this also means that JPanel is havi...