java

How to set up Eclipse TPTP

I need to profile a java application for a customer. It's an eclipse/maven project, so I decided on using eclipse TPTP ( http://www.eclipse.org/tptp ). I tried to install eclipse TPTP through the update manager from a standard eclipse installation, but I gave up because of the unbelievable complex setup and downloading of dependencies w...

ResultSet: Retrieving column values by index versus retrieving by label

When using JDBC, I often come across constructs like ResultSet rs = ps.executeQuery(); while (rs.next()) { int id = rs.getInt(1); // Some other actions } I asked myself (and authors of code too) why not to use labels for retrieving column values: int id = rs.getInt("CUSTOMER_ID"); The best explanation I've heard is some...

SMTP with CRAM-MD5 in Java

I need to send email through an (external) SMTP server from Java however this server will only accept CRAM-MD5 authentication, which is not supported by JavaMail. What would be a good way to get these emails to send? (It must be in Java.) ...

How do I catch ClassCastException?

I'm trying to catch a ClassCastException when deserializing an object from xml. So, try { restoredItem = (T) decoder.readObject(); } catch (ClassCastException e){ //don't need to crash at this point, //just let the user know that a wrong file has been passed. } And yet this won't as the exception do...

Remote log viewer for Java/Glassfish log files

I'm looking for a log viewer with similar capablilties as Chainsaw, in which I can tail Glassfish log files over for instance SSH/SCP. Does anyone know if such a tool exist? ...

Importing Delphi Web Services into Java

I have a web server built in Delphi, and I'm trying to consume its web services on Java (I'm using Eclipse IDE) by creating a Web Service Client through the Eclipse wizard. The Web Services Explorer recognice the WSDL file, but when trying to create the client, the wizard says there's an "unexpected attribute" and does not create any fil...

Java core API anti-Patterns. What is wrong?

Hi, Despite that the work of the guys from SUN with the Java core API is awesome, as they are humans, they are not infallible. I have read in several books some criticism about Some huge mistakes that (my guess) are still there for backward compatibility and legacy code. My question here is which ones do you know? As examples: Observa...

Tools for finding Shared Mutable data bugs in Java

I have a large legacy system to maintain. The codebase uses threads all over the place and those threads share a lot of mutable data. I know, sounds bad. Anyway, don't answer "rewrite the whole application from scratch" or I'll vote you down :-) I have tried to run some static analysis tools on the codebase, but none of those seem to cat...

How do I include a header into my site that is hosted externally?

We are hosting a site for a client and they want us to include the header they have on their server into the pages we are hosting. So whenever they change it, it will automatically change on our site. We are attempting to use the "include" tag in our JSP code. The code we are using is as follows: <%@ include file="www.CLIENT.com/CLIE...

What is the best way for converting phone numbers into international format (E.164) using Java?

What is the best way for converting phone numbers into international format (E.164) using Java? Given a 'phone number' and a country id (let's say an ISO country code), I would like to convert it into a standard E.164 international format phone number. I am sure I can do it by hand quite easily - but I would not be sure it would work c...

Import package.* vs import package.SpecificType

Would it suppose any difference regarding overhead to write an import loading all the types within one package (import java.*); than just a specific type (i.e. import java.lang.ClassLoader)? Would the second one be a more advisable way to use than the other one? ...

ClassDefNotFound first time I start Tomct from within Eclipse

I have a tomcat application which, the first time I start Tomcat after starting eclipse, I get a n odd NoClassDefFoundError. If I then stop and restart tomcat through eclipse, it works fine. I have single, double, and triple checked the classpath and everything seems fine. Anyone ever seen anythign like this before? relevant versions...

Client side Callback in GWT

I'm trying to create a logger for a GWT application as an exercise to evaluate GWT. What I specifically want to do is have it so that I can post messages to a client side label at any point from the server side. So, if some interesting stuff has happened on the server the client can be updated. My First question is, is this possible, I ...

Preprocessing source code as a part of a maven build

I have a lot of Java source code that requires custom pre-processing. I'd like rid of it but that's not feasible right now so I'm stuck with it. Given that I have an unfortunate problem that shouldn't have existed in the first place, how do I solve it using maven? (For the full story, I'm replacing a python-based build system with a ma...

String Operations in Java

I know this is a bit of a newbie question, but are there equivalents to C#'s string operations in Java? Specifically, I'm talking about String.Format and String.Join. ...

ListCellRenderer not Firing Events on Child Components

The following ListCellRenderer does not receive click events on the nested ComboBoxes. Do I need to enable something? class FilterCellRenderer implements ListCellRenderer { public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { Filter filter = (Filter)...

Java GUI Resolution Independant Scaling

Hi, I'm working on a large legacy java application for which an important feature was automatic scaling of GUI Components based on monitor resolution. We are upgrading the JVM on which it runs from 1.4.2 to 1.6 and now the scaling is broken due to a change in the implementation of java.awt.Container.getPreferredSize(). getPrefferedSiz...

Named Entity Recognition Libraries for Java

I am looking for a simple but "good enough" Named Entity Recognition library (and dictionary) for java, I am looking to process emails and documents and extract some "basic information" like: Names, places, Address and Dates I've been looking around, and most seems to be on the heavy side and full NLP kind of projects. Any recommendat...

Catching exceptions with tomcat and a servlet

I have set-up tomcat to catch all my exceptions and pass them to a servlet with the following in web.xml. <servlet-mapping> <servlet-name>exception</servlet-name> <url-pattern>/exception</url-pattern> </servlet-mapping> <error-page> <exception-type>java.lang.Exception</exception-type> <location>/exception</location> </er...

Expose Java class as SOAP WebService - how ?

I am looking for a framework to turn given Java class into WebService (may be with some limitations on method parameters etc) Thanks ...