java

Regex Question - One or more spaces outside of a quote enclosed block of text

I want to be replace any occurrence of more than one space with a single space, but take no action in text between quotes. Is there any way of doing this with a Java regex? If so, can you please attempt it or give me a hint? ...

Should I create a new quartz job and trigger or one job and many triggers?

I am looking to use quartz to schedule emails, but I'm not sure which approach to take: Create a new job and trigger whenever an email is scheduled OR Create a single job, and create a new trigger each time an email is scheduled I need to pass the message/recipient etc either way, and I'm not sure whether creating heaps of jobs will ...

How do I generate sql scripts for process definition deployment in jBPM?

I'm looking into integrating jBPM with my current project, so far so good just including the jpdl jar in my ear and using the spring modules 0.8 jbpm module, however I've got to have a reasonable way of going from my changes to to the process definition in the designer to deployment in production. The path has to be repeatable in a num...

Java Serial Communication on Windows

I've been looking around for a Java API that can communicate with Serial on Windows/Win32 but many of the API's I've checked out are either for Linux, too outdated, or just had bad critics. Can someone recommend one to me that they've tried or knows about that is easy to implement on Windows XP? ...

Lookup Op performance

I'm trying to squeeze some more performance out of my rendering pipeline. The (by far) slowest part is performing a java.awt.imaging.LookupOp on a large image. The image size is about 2048x2048. I have figured out that having the filter done along with the drawing operation is much faster than calling the filter method. However thi...

Querying ManyToMany relationship with Hibernate Criteria

I'm not sure how to describe this problem, so I think an example is the best way to ask my question: I have two tables with a manyToMany relationship: DriversLicence <-> LicenceClass LicenceClass is things like "Car", "Motorbike", and "Medium Rigid". Using Hibernate Criteria, how can I find all licences that have both "Car" and "Moto...

How do I sort a MultiMap<k,v> in java?

I am new to using the MultiMap interface, any help would be great. ...

Java RS-232 Communication on Windows

Does anyone know of a good Java API for controlling RS-232 devices in a WIN32 enviroment? I've tried RXTX but they don't support RS232, only RS-485. ...

How to find two adjacent repeating digits and replace them with a single digit in Java?

I need to find two adjacent repeating digits in a string and replace with a single one. How to do this in Java. Some examples: 123345 should be 12345 77433211 should be 74321 ...

Is there a SoftHashMap in Java?

I know there is a WeakHashMap in java.util, but since it uses WeakReferences for everything, which is only referenced by this Map, referenced objects will get lost on the next GC cycle. So it's nearly useless if you want to cache random data, which is very likely to be requested again without being Hard-linked the rest of the time. The b...

Deserializing a legacy XML structure in xstream

I'm trying to deserialize an xml structure that looks like this: <somecontainer> <key1>Value1</key1> <key1>Value2</key1> <key2>Value3</key2> <key2>Value4</key2> </somecontainer> I can basically choose what kind if element to deserialize to, maybe something like a List of Pair or something. The essence here is that the ...

Best way to automagically migrate tests from JUnit 3 to JUnit 4?

I have a bunch of JUnit 3 classes which extend TestCase and would like to automatically migrate them to be JUnit4 tests with annotations such as @Before, @After, @Test, etc. Any tool out there to do this in a big batch run? ...

In a Java thread running as root, how can we apply Unix rights specific to a logged-in user ?

We have a Java program run as root on Unix, that therefore can read for example the content of the folders /home/user1 and /home/user2. However, if the Unix user "user1" is logged in in our application, he should not be able to access "/home/user2" data. We would like to use directly the Unix rights and not recreate all the permissions ...

Is there a way to the hide win32 launch console from a Java program (if possible without JNI)

You launch a java program from a console (maybe using a .bat script). I don't want the console to remain visible, I want to hide it. Is there a simple way to do this ? Without JNI ? Thanks. ...

capturing global keypresses in Java

So I want to trigger an event (pausing/unpausing some media) whenever the user presses spacebar anywhere in the my Swing app. Since there are so many controls and panels that could have focus, its not really possible to add keyevents to them all(not to mention gross). So I found KeyboardFocusManager.getCurrentKeyboardFocusManager()....

Why are Maps returned by a JAX-WS call always empty?

My web service method returns a Page object which includes the following methods: public Map<String,String[]> getParameters() { ... } public setParameters(Map<String,String[]> parameters) { ... } On the client side, the JAX-WS generated getParameters() method returns a Parameters object which provides a getEntry() method that returns ...

How to get Websphere 6.1 port number

I'm currently working on a WebSphere 6.1 Web Project. In my java code, how can i get the current running application port? ...

Get notification on a Java process termination

There is a console Java application which is supposed to run untill it is stopped by Ctrl+C or closing the console window. How that application can be programmed to execute a clean up code before exit? ...

Controlling the classpath in a servlet

My servlet application includes a number of library .jars, some of which contain embedded log4j.xml or log4j.properties files. I'd like to ensure that log4j finds my log4j.xml first! I've tried searching for some specification of the priorities of the various classpath elements in a servlet (e.g. does WEB-INF/classes always precede WEB-I...

How to create own header.jsp in JBoss Portal with language support?

I want to create own header.jsp file instead of the one included in the JBoss Portal 2.6 but have to support the locale set by the user. The original header.jsp does not contain any i18n and I don't know how to do it, especially how to get the actual locale. ...