java

What does "Message Catalog Not Found" mean?

I have a MDB running in WebSphere, when it tries to pull a message off an MQ Queue the following exception is thrown: com.ibm.mq.MQException: Message catalog not found Any idea how to resolve this? ...

How do I get which JRadioButton is selected from a ButtonGroup

I have a swing application that includes radio buttons on a form. I have the ButtonGroup, however, looking at the available methods, I can't seem to get the name of the selected JRadioButton. Here's what I can tell so far: From ButtonGroup, I can perform a getSelection() to return the ButtonModel. From there, I can perform a getActi...

escaping formatting characters in java String.format

This question is pretty much the same as this .Net question exept for java. How do you escape the %1$ characters in a java string.format? THe reason I need to do this is that I'm building up a string that will later have more info inserted into it. I've thought of having one of the args just be "%1$" but that doesn't seem to be very el...

Can I make my Applet end more gracefully?

I have a JApplet which I contains various Swing components. It also starts a couple of extra threads in the init() and generally does other pretty standard applet-y things. If I close the browser window containing the Applet, the JRE doesn't die (the icon remains in the system tray) until all the browser's windows have been closed (ie ...

Simple java client code for Web Service - something to do with QName?

I am getting the following error when I get to the line that invokes a REALLY BASIC web service I have running on Tomcat/Axis. Element or attribute do not match QName production: QName::=(NCName':')?NCName Have I got something wrong with QName?- I can't even find any useful information about it. My client code is below: import javax...

Are there any Ant conventions similar to Maven2 conventions?

For the past 2 years-(ish) I've been using Maven2 for my build/continuous integration solution. I used Ant a bit before that but really didn't get a lot of experience with it. Now I've taken a new job and the team I'm on now uses Ant. What I'm wondering about is this: In Maven we had directory conventions for seperating our java so...

How do I create a named log in $TOMCAT_HOME/logs for my servlet?

I'm currently logging via the simplest of methods within my servlet using Tomcat. I use the ServletConfig.getServletContext().log to record activity. This writes to the localhost.YYYY-MM-DD.log in $TOMCAT_HOME/logs. I don't want to get away from the simplicity of this logging mechanism unless absolutely necessary. But I would like to...

How to set a long Java classpath in MSDOS/Windows?

I'm trying to run a particular JUnit test by hand on a Windows XP command line, which has an unusually high number of elements in the class path. I've tried several variations, such as: set CLASS_PATH=C:\path\a\b\c;C:\path\e\f\g;.... set CLASS_PATH=%CLASS_PATH%;C:\path2\a\b\c;C:\path2\e\f\g;.... ... C:\apps\jdk1.6.0_07\bin\java.exe -cl...

Primary key from inserted row jdbc?

Is there a cross database platform way to get the primary key of the record you have just inserted? I noted that this answer says that you can get it by Calling SELECT LAST_INSERT_ID() and I think that you can call SELECT @@IDENTITY AS 'Identity'; is there a common way to do this accross databases in jdbc? If not how would you suggest ...

Spring initialization order

Suppose I have a couple of spring beans: <beans> <bean name="A" ... /> <bean name="B" ... /> </beans> "B" exposes a remote service that doesn't need "A". Assume that "A" takes a non-negligble time to load. What this means is that during a restart cycle, the application hangs the remote client, which can actually connect to the ...

Is there a class or method in Java that will check if a string is a SQL Server keyword?

I want something that can check if a string is "SELECT", "INSERT", etc. I'm just curious if this exists. ...

Replace first line of a text file in Java

I have a text file where I want to change only the first line of the file. The file could be millions of rows long, so I'd rather not have to loop over everything, so I'm wondering if there is another way to do this. I'd also like to apply some rules to the first line so that I replace instances of certain words with other words. Is t...

Eclipse & Tomcat: How to specify which folder is served from the project?

I'm using Eclipse 3.4 and Tomcat 5.5 and I have a Dynamic Web Project set up. I can access it from http://127.0.0.1:8080/project/ but by default it serves files from WebContent folder. The real files, that I want to serve, can be found under folder named "share". This folder comes from CVS so I'd like to use it with its given name instea...

Automatic Java Error Reporting Systems

Does anyone know of a system for automatic error reporting in java? We have a server product that is installed on client servers. The idea is that our server would phone home with the details of an error to one of our servers, which then enters a bug in our bug tracker. Preferable, this would happen over http. It wouldn't happen for all ...

Appropriate Tomcat 5.5 start-up parameters to tune JVM for extremely high demand, large heap web application?

We have recently migrated a large, high demand web application to Tomcat 5.5 from Tomcat 4 and have noticed some peculiar slowdown behavior that appears to be related to JVM pauses. In order to run our application and support increased load over time on Tomcat 4, many not so standard JVM parameters were set and tuned as per the below, a...

Best free Java .class viewer?

I've used DJ Java Decompiler, which has a handy GUI, but it seems as if the latest version is only a trial and forces you to purchase the software after some period of days (I recall using an earlier free version about a year ago at a previous job). I'm aware of Jad and Jadclipse, but what I loved about DJ Java Decompiler was that it in...

Is there a way to set timeouts in tomcat?

Can I set timeouts for JSP pages in tomcat either on a per page or server level? ...

Log4j usage - how to customize the event ID when logging to Windows Event Log?

I'm adding windows event logging functionality to an existing Java application and I'd like to utilize event ids(our admin is using them already). Is there a way to specify the event ID when logging with NTEventLogAppender? ...

Best way to list files in Java, sorted by Date Modified?

I want to get a list of files in a directory, but I want to sort it such that the oldest files are first. My solution was to call File.listFiles and just resort the list based on File.lastModified, but I was wondering if there was a better way. Edit: My current solution, as suggested, is to use an anonymous Comparator: File[] files = ...

What's a good Java API for creating Word documents?

I have a new app I'll be working on where I have to generate a Word document that contains tables, graphs, a table of contents and text. What's a good API to use for this? How sure are you that it supports graphs, ToCs, and tables? What are some hidden gotcha's in using them? Some clarifications: I can't output a PDF, they want a W...