java

Spring-WS: how to use WebserviceTemplate with pre-generated SOAP-envelope

Can you use a Spring-WS WebserviceTemplate for calling a webservice and avoid that it generates a SOAP-envelope? That is, the message already contains an SOAP-Envelope and I don't want that the WebserviceTemplate wraps another one around it. :-) The reason I want this is that I'd like to call a webservice that uses ws-security and do no...

Most elegant way to detect if a String is a number?

Is there a better, more elegant (and/or possibly faster) way than boolean isNumber = false; try{ Double.valueOf(myNumber); isNumber = true; } catch (NumberFormatException e) { } ...? Edit: Since I can't pick two answers I'm going with the regex one because a) it's elegant and b) saying "Jon Skeet solved the problem" is a tau...

Java REST client without schema

Goal Java client for Yahoo's HotJobs Resumé Search REST API. Background I'm used to writing web-service clients for SOAP APIs, where wsimport generates proxy stubs and you're off and running. But this is a REST API, which is new to me. Details REST API No WADL No formal XML schema (XSD or DTD files). There are example XML request/...

JavaFX and java

Simple question...Can I mix in my desktop application java and javafx code? If it is possible could you provide me with some link with examples? Or could I pack my custom made javafx CustomNode-s in a jar and use them in my project side by side with standard SWING components? ...

How to undo changes on JSpinner?

I need to validate the user input of a JSpinner, and if invalid, I need to undo (rollback) the value change. What is the best way to do it? ...

How do I use a 32 Bit COM object from a 64 bit process?

I Use Jacob (JAVA COM Bridge) on a 64 Bit Machine and want to load COM Objects from a 32 bit DLL. How can I do that? ...

debug a dll from java java->jni.dll ->app.dll -> app.dll

how can I debug a dll that is not loaded by the java application. The scenario is this: my java app is loading the jni.dll that is using another dll and that dll is using another dll. java<->jni.dll<->dll<->dll I have the source code for all modules I am using visual studio express when debugging the jni.dll but what should I do to ...

Test class extending test class in dependency module

I've got a test class in a module that extends another test class in one of its dependency modules. How can I import the dependency's test code into the test scope of the dependent module? To illiterate, I've got two modules, "module-one" being a dependency of "module-two". SubTestCase is a subclass of TestCase. module-one \...

How good is Apache POI word support?

On the web page, it looks like there is no current development in the old style .doc. Is it good enough to create complex documents? Can it read all .docs without crashing? What features do (not) work? I am not currently interested in the XML based formats, as I don't control the client side. The excel support seems to be much bet...

Generate CRUD UI (Swing)

I am looking for a tool/framework to (automatically) generate a Swing user interface to perform CRUD operations on an underlying database. I would also like to configure the database fields that should be exposed. Something like django (via modelforms) or ruby on rails features, but in a Java desktop environment. ...

Hibernate: How to make Hibernate delete records from child table when deleting parent if child is linked to parent with many-to-one?

Lets say I have two tables - "child" and "parent" with many-to-one relation. What I need is to delete child entries if parent record is deleted. It is not a problem if I link child table from parent by creating one-to-many association in parent.hbm and set cascade="all-delete-orphan". The problem is I don't want one-to-many relation o...

Set Variable from an Array directly into a List of Variables in Java

I have a Java method which returns an array of doubles. I would then like to store these values in individual variables in the calling function. Is there an elegant way of doing this in Java. I could write it as this: double[] returnValues = calculateSomeDoubles(); double firstVar = returnValues[0]; double secondVar = returnValues[1];...

What are the alternatives to comparing the equality of two objects?

http://leepoint.net/notes-java/data/expressions/22compareobjects.html It turns out that defining equals() isn't trivial; in fact it's moderately hard to get it right, especially in the case of subclasses. The best treatment of the issues is in Horstmann's Core Java Vol 1. If equals() must always be overridden, then what i...

What are the best Java code generation tools or plugins to use in Eclipse?

I'm aware of the built in code generation and refactoring one can do with the "Source" and "Refactor" menu items in Eclipse. I also use the Commonclipse plugin to easily make use of the Apache Commons classes that build hashCode, toString, equals methods. What other plugins or tools should I be aware of for generating Java source easi...

Unit testing with Spring Security

My company has been evaluating Spring MVC to determine if we should use it in one of our next projects. So far I love what I've seen, and right now I'm taking a look at the Spring Security module to determine if it's something we can/should use. Our security requirements are pretty basic; a user just needs to be able to provide a usern...

Java formal type parameter definition (Generics)

Hi, I'd like to define a generic type, whose actual type parameter can only be One of the numeric primitive wrapper classes (Long, Integer, Float, Double) String I can meet the first requirement with a definition like this public final class MyClass<T extends Number> { // Implementation omitted } But I can't figure out how to...

What are the parameters for a GridLayout?

private static final GridLayout layout = new GridLayout( 3, 1, 1, 0 ); in this line of code what do the numbers represent and how do you use them to arrange the checkboxes and buttons in the window? ...

Checkboxes display?

JCheckBox special = new JCheckBox ("\nSpecial - $17.95" + "\nMeatball, Sausage, Mushroom, Onion, Pepperoni & Pepper"); In this line of code, how do you make the checkbox make the "..." into two lines? ...

bypass FreeMarker caching?

Is it possible to bypass the Freemarker cache when certain templates are requested? I realise that I'll probably have to implement my own TemplateLoader in order to do this, but even so, I can't see a way to check the cache when say template A is requested, but bypass it when template B is requested? If this is not possible, I'll just h...

Persistent cookies from a servlet in IE

I have a cookie which is generated from a servlet and that I would like to be persistent - that is, set the cookie, close down IE, start it back up, and still be able to read the cookie. The code that I'm using is the following: HttpServletResponse response = (HttpServletResponse) FacesContext.getCurrentInstance() .getExterna...