java

Remove all non-"word characters" from a String in Java, leaving accented characters?

Apparently Java's Regex flavor counts Umlauts and other special characters as non-"word characters" when I use Regex. "TESTÜTEST".replaceAll( "\\W", "" ) returns "TESTTEST" for me. What I want is for only all truly non-"word characters" to be removed. Any way to do this without having something along the lines of "[^...

In Eclipse, how do I change the default modifiers in the class/type template?

Eclipse's default template for new types (Window > Preferences > Code Style > Code Templates > New Java Files) looks like this: ${filecomment} ${package_declaration} ${typecomment} ${type_declaration} Creating a new class, it'll look something like this: package pkg; import blah.blah; public class FileName { // Class is acces...

accessing javascript from inside java

Hello all. I know that there are lots of examples out there on this, but they all feel a little dated (even the sun docs) so I'm asking here to make sure what I'm doing is up to date. How would I go about talking to javascript from inside a java applet? Something simple like how to call alert() is all I'm looking for. Bonus points for a ...

How to write to log files in java?

I have made a java application and wants to generate log files so whenever my client would encounter some problem, he can deliver me those log files so that I can correct my code accordingly. Kindly provide me a small sample program that writes a statement to a log file. Kindly mention the .class files you are using with their full imp...

How to parse four digit year only (with Joda Time)?

Is there a way to force Joda time to parse dates only when they contain four digit years? For example: 2009-11-11 - should parse 09-11-11 - should not parse Tried the following code: DateTimeFormatterBuilder builder = new DateTimeFormatterBuilder(); DateTimeFormatter formatter = builder.appendYear(4, 4).appendLiteral('-').appendMont...

How do I Bind a Collection (ArrayList) returned by a Web Service to JTable in Swing?

I am developing a business application in .NET and Java. In .NET I have developed a web-service which uses basicHttpBinding. I am consuming this web-service in a Java client. The web-service is working fine, calling it in the Java code returns an ArrayList collection of Holding class. This class is described below: @XmlAccessorType(XmlA...

Java: Can a desktop App log-in in a web app and retrieve a "session" object to authenticate itseft in other apps which trust the web app?

I don't know if this question has any sense, but this is what my boss want. I work in a company with an intranet web. In my department we have developed an application wich connects to a Bussiness Object server and executes and prints reports. This is a regular client/server app with our own user/password manintenance to log in. My b...

Swing GUI components too tighly packed

Hi, In the Java Swing app I made it seems to me that all the component are too tightly packed. In QT one can specify padding and margins for the layout. Is there something similar for swing? Here is a screen shot of my application that I thing is too tight (is it? what do you think?. Thanks. ...

Concurrency issues in Spring DAOs with 3.0.0.RC1

Hi guys, After upgrading from Spring 3.0.0.M4 to 3.0.0.RC1 and Spring Security 3.0.0.M2 to 3.0.0.RC1, I've had to use a security:authentication-manager tag instead of defining an _authenticationManager like I used to in M4/M2. I've done my best at defining it, and ended up with this: <security:authentication-manager alias="authenticati...

Getting active channels of a user in asterisk-java

Is there a way to get all currently active channels of an IAX useraccount with asterisk-java? Thanks Dominik ...

Force a class to override the .equals method

I have a bunch of class who implement a common interface : Command. And this bunch of class goes to a Map. To get the Map working correctly, I need to each class who implements Command to override the Object.equals(Object other) method. it's fine. But i whould like to force the overriding of equals. => Have a compilation error when ...

Difference between DTO, VO, POJO, JavaBeans?

Have seen some similar questions here and here. Can you also please tell me the contexts in which they are used?? Or the purpose of them? ...

jBPM + Spring transactions sharing and scope

Hi all. I've inherited an app using jBPM and Spring and am trying to figure out if it is configured the way it should be. First question: Does jBPM span a single JTA (JDBC and/or Hibernate) transaction across multiple actions in the same transition by default? If not, can it be configured to? So in the example below is there a way to sp...

problem of testing file worker in java

Hi I have a question which is described below: What problems would arise for testing a Java class which counts number of words in a file? The function's signature is below: public int wordCount(String filename) Well, this is a junit testing question. If you know the problem, what is the solution of that? ...

wsimport multiple generated wsdl's

I am using jbossws (with jax-ws) to serve 3 webservices generated from annotated POJOs. These 3 webservices share a few data classes and also have a common method (ping). They all reside in the same java package (namespace) The 3 WSDL files are generated automatically by jbossws at deploy time. Now I want to generate client code using ...

Overriding HashMap equals method in Java

I noticed in the source code for HashMap it lists the equals method as final. Why is it that when I override it I do not get a compile error? public class Test extends HashMap<Object, Object> { @Override public boolean equals(Object o) { return false; } } Java HashMap equals method: public final boolean equals(O...

SAXParseException: 'Attribute "" bound to namespace "null" was already specified for element "metric"'

At work, we have just migrated an old web-app from struts 1.1 to 1.2.9 (hopefully first steps to moving to 1.3), but we are now having problems with the commons digester. Struts 1.2.9 uses commons-digester 1.6. When we try to parse one of our XML files we get the exception: org.xml.sax.SAXParseException: Attribute "" bound to namespace...

Best Java data structure to store a 3 column oracle table? 3 column array? or double map?

Hello :) What is the best data structure to store an oracle table that's about 140 rows by 3 columns. I was thinking about a multi dimensional array. By best I do not necessarily mean most efficient (but i'd be curious to know your opinions) since the program will run as a job with plenty of time to run but I do have some restrictions...

Spring security and Struts 2

I have a struts2 action with an @Secured({"ROLE_ADMIN"}) to secure the execute method. In the execute method i assign a message to a member variable of the action, then return SUCCESS and end up on the jsp page. On the page I retrieve the actions member variable with <sroperty. private String greeting; public String execute() throws Ex...

Creating a CFString object with JNA

I'm trying to get the hang of using JNA with Mac OS X. I want to access a Carbon library, for which there is no Cocoa equivalent, so Rococoa can't help me (I think...) I'm stuck when trying to call a Carbon function that requires CFStringRef as a parameter. How can I create a CFStringRef from a Java String? Here's my attempt so far: ...