java

How do you manage embedded configuration files and libraries in java webapps?

I'm currently working on a j2ee project that's been in beta for a while now. Right now we're just hammering out some of the issues with the deployment process. Specifically, there are a number of files embedded in the war (some xml-files and .properties) that need different versions deploying depending on whether you are in a dev, testin...

How to calculate the difference between two Java java.sql.Timestamps?

Please include the nanos, otherwise it would be trivial: long diff = Math.abs(t1.getTime () - t2.getTime ()); [EDIT] I want the most precise result, so no doubles; only integer/long arithmetic. Also, the result must be positive. Pseudo code: Timestamp result = abs (t1 - t2); Examples: t1 = (time=1001, nanos=1000000), t2 = (time=99...

How can I ignore DTD validation but keep the Doctype when writing an XML file?

I am working on a system that should be able to read any (or at least, any well-formed) XML file, manipulate a few nodes and write them back into that same file. I want my code to be as generic as possible and I don't want hardcoded references to Schema/Doctype information anywhere in my code. The doctype information is in the source d...

Do you know a free or open source website spell-checker?

We are looking for a free to use website software for spell checking our sites before they go to production. A basic search online took me to these pages: Net MECHANIC Text Trust Orango I did the trial in NetMechanic and I got a bogus email with no result and encouraging me to buy their paid subscription. Any suggest...

java.util.logging.Logger and log4j

I am trying to compile the code from here: http://www.brackeen.com/javagamebook/#download (Chapter 6) and am having trouble. I don't understand how java.util.logging.Logger and log4j work together, but that seems to be the issue. The errors I get are all on the log.error() or log.warn() method calls. Here is the output from NetBeans: ...

C# on Linux - Anyone got an opinion based on experience using mono?

Is it worthwhile learning C# if you are a Linux user? There is Mono but it seems destined to always be behind the curve with the constant threat of MS action if they start to lose money. Currently I am leaning more towards Java as its is fully GPLed and there are no major threats of software patents. It already has a big oss community b...

Hibernate not respecting MySQL auto_increment primary key field

Hello, I am trying to learn how Hibernate works, and I am running into an almost unacceptable learning curve. I can't see how to get Hibernate to respect the auto_increment policy for my objects. Instead, it is overwriting entries in the database with existing IDs, beginning with 1. I have a simple Foo object, backed by a MySQL table d...

Factory pattern

I've been trying to create a factory (in Java) that prohibits subclassing of the factory product and prevents the concrete factories from being used by anyone except the abstract factory. What do you think of this... class Client { public static void main(String[] args) { Animal animal = Animal.create(Lion.class); ...

Sending RTP using Java

What would be the best way to send/receive audio data over RTP using Java? I have read a little about JMF, but it seems to be out of date. Are there are other viable alternatives. ...

Piecemeal Conversion from Struts to Tapestry 5

I have a Struts (1.3.8) application that I'd like to convert to Tapestry 5. There will probably not be time to do the whole conversion in one fell swoop. I'd like to deliver new functionality in Tapestry and convert existing Struts / JSPs as time permits. Has anyone attempted something like this? Can Struts and Tapestry co-exist? ...

Setting JFreeChart / Cewolf X Axis Interval

I am trying to display some charts on a web app that has data for every minute. The problem is when I try to view an hours worth of data (default) you just see a bunch of hash marks. Is there a way to set the interval so that you it automatically sents 5 marks that display the date time (YYYY-MM-DD HH:MM:SS). Current: http://img255....

How to use Java timezone id in a Windows (non-Java) application?

I need to add timezone information to a db table with user maintained locations. The data will be accessed mostly from Java code but there is also some PL/SQL and Win32 (Delphi) code which needs to understand the timezone information. It seems straight forward to use the id from java.util.TimeZone. Java can easily convert that (obviousl...

Check if variable null before assign to null?

Is variable assignment expensive compared to a null check? For example, is it worth checking that foo is not null before assigning it null? if (foo != null) { foo = null; } Or is this worrying about nothing? ...

PDF to text tool or Java library?

I need to convert a PDF to normal text (it's the "statement of votes" from our county registrar). The files are big (2000 pages or so) and mostly contain tables. Once I get it into text, then I'm going to use a program I'm writing to parse it and put the data into a database. I've tried the 'Save as text' function in Adobe Reader, but it...

Testing EJB 3.0 components

I've got a couple of questions concerning the integrated testing EJB 3.0 components using JUnit. In your JUnit tests you can inject to session beans resource-local entity managers and therefore "simulate" ejb-container. But what if... What if you need to test if transaction attributes on your ejb methods are handled properly? Can thi...

If Quartz Scheduler dies, how do I stop the child Java processes that it started?

I'm currently using Quartz Scheduler as a replacement for Cron on our Windows 2003 Server Box. I have two specific Jobs that needed to be started in a new VM, so I'm using the ProcessBuilder object in Java 5 to get my "Process" object. The problem I'm running into is when our Quartz Scheduler JVM stops, the 2 jobs in separate JVM's kee...

Call a ColdFusion function on another server?

I have a Java class I have to run, my current web host (shared) will not allow Java. I need to host it on another server. I was told I can't call Java from ColdFusion on a separate server, but what if I call a CF function on the 2nd server then have that function call the Java class, return the data to CF then that function go back to ...

How to implement a most-recently-used cache

What would be the best way to implement a most-recently-used cache of objects? Here are the requirements and restrictions... Objects are stored as key/value Object/Object pairs, so the interface would be a bit like Hashtable get/put A call to 'get' would mark that object as the most recently used. At any time, the least recently used ...

MulticastSocket not responding after failure

I get a SocketException when trying to call joinGroup(addr) on MulticastSocket. This is only happening on a Windows machine that we have setup to auto start our appliction when the machine is booted up. It seems like the exception is thrown because Windows has not completely finished its startup process and here is the exception. java...

Problem with threads.

*I'm using Java. I have this thread, agent, that explores a room to determine its size and clean it if it's dirty. Then I have the interface, which draws the agent as it explores the environment. Agent is subclassed from Thread, and Java takes care of managing the threads. All I do is create the thread and say object.start(). This work...