java

Java RMI not closing socket after lease expiration

My RMI enabled application seems to be leaking sockets. I have a Java application providing a service over RMI. It is using the Java SE 1.6 RMI implementation running on Linux. The problem I am observing is that if a client obtains a reference to my Remote object, using the Registry, and then the connection is severed abruptly (power ...

Can I use regular expressions to find a method on a class in java?

I know how to find a method in java using a fixed string, someClass.getMethod("foobar", argTypes); but is there a way to use a regular expression rather than a fixed string to find a method on a given class? An example of the usage might be if I wanted to find a method that was called either "foobar" or "fooBar". Using a regular exp...

Find where java class is loaded from

Does anyone know how to programmaticly find out where the java classloader actually loads the class from? I often work on large projects where the classpath gets very long and manual searching is not really an option. I recently had a problem where the classloader was loading an incorrect version of a class because it was on the clas...

JSTL, Beans, and method calls

I'm working on a JSP where I need to call methods on object that come from a Bean. The previous version of the page does not use JSTL and it works properly. My new version has a set up like this: <jsp:useBean id="pageBean" scope="request" type="com.epicentric.page.website.PageBean" /> <c:set var="pageDividers" value="<%= pageBean.getPag...

Make a Perl-style regex interpreter behave like a basic or extended regex interpreter

I am writing a tool to help students learn regular expressions. I will probably be writing it in Java. The idea is this: the student types in a regular expression and the tool shows which parts of a text will get matched by the regex. Simple enough. But I want to support several different regex "flavors" such as: Basic regular expres...

Bus or listeners/delegates in client-side Swing application?

Building a client-side swing application what should be notified on a bus (application-wide message system, similar in concept to JMS but much simpler) and what should be notified using direct listeners? When using a bus, I always have an unescapable feeling of "I have no idea who uses that and where". Also, no set order, hard to veto e...

How do I pass model data beween a view state and action state in Spring Web Flow 2.

In the Web Flow below I bind form data to a flow variable (lifeCycleForm) on a submit event in the view state. I have verified that the name, label and description properties are all populated as expected. However, when the expression in the action state is evaluated all three properties are null. My form bean is serializable and I am j...

Date time parsing that accepts 05/05/1999 and 5/5/1999, etc...

Is there a simple way to parse a date that may be in MM/DD/yyyy, or M/D/yyyy, or some combination? i.e. the zero is optional before a single digit day or month. To do it manually, one could use: String[] dateFields = dateString.split("/"); int month = Integer.parseInt(dateFields[0]); int day = Integer.parseInt(dateFields[1]); int year ...

Beanshell catch(ex): Exception or Throwable?

What type of exception is caught by the beanshell catch(ex): Exception or Throwable?. Example: try { .... } catch (ex) { } ...

Java Web Application Sync Question

Let's say I have a class in my web app called class "Foo". It has an initialise() method that is called when the bean is created using Spring. The initialise() method then tries to load an external service and assign it to a field. If the service could not be contacted, the field will be set to null. private Service service; publi...

Java Applet Locale setting

I am running an english language version of WindowsXP, but have set Spanish as my only accepted language in Firefox. I had naively expected the browser's language to be set as the default when I load an applet in a browser session, but this does not appear to be the case. The applet starts up in English, the default language of the OS. ...

Importing the content of another web resource using JSTL

I have a JSP page that will display the exact content of another web page on a different server. My understanding was that c:import from the JSTL should be able to include content from files that are not part of the current web application. I added c:import url="page on my server in a different application" and it works fine, but when ...

How to use a method Revision

I am very new to Java. My assignment is to create my own method and then create a class to test it in. My question, do I create the method separate of the class, or within the class? If it is separate of the class, how do I get the class to access my method? (Are they saved as two separate files?) This is what I have so far, but I am g...

How do I combine multiple BIRT reports

We currently have a whole suite of report designs that cover various parts of our app, and these reports are generated on demand by our users. I want to be able to bundle up several of these reports into a single report to return to the user. I initially hacked up a custom report builder that generated report design files using segment...

How do I programmatically determine operating system in Java?

I would like to determine the operating system of the host that my Java program is running programmatically (for example: I would like to be able to load different properties based on whether I am on a Windows or Unix platform). What is the safest way to do this with 100% reliability? ...

NoClassDefFoundError without a class name

I'm not quite sure if this is specific to Sun Java Systems Application Server but there are occasions where I run into a NoClassDefFoundError where the class in question, the one not found, is not mentioned in the error. Does anyone know what conditions would lead to a NoClassDefFoundError being raised without specifying which class w...

How do I write a Java function that returns a typed instance of 'this' and works when extended?

Hi, This is a bit of a lazyweb question but you get the rep so :-) I have a Java class that returns instances of itself to allow chaining (e.g. ClassObject.doStuff().doStuff()) For instance: public class Chainer { public Chainer doStuff() { /* Do stuff ... */ return this; } } I would like to extend this c...

packaging tagfiles in jar

how can i package tagfiles in a jar so it can be reused acrossed multiple projects? ...

Which is the best book to start Java ME?

I am looking for a book to start programing using Java Platform, Micro Edition (Java ME). Which book will you recommend to a reader who knows Java and have some knowledge of Java EE? Thanks everyone in advance. ...

convert string to byte[] in java

We try to convert from string to Byte[] using the following Java code: String source = "0123456789"; byte[] byteArray = source.getBytes("UTF-16"); We get a byte array of length 22 bytes, we are not sure where this padding comes from? how do i get an array of length 20? ...