java

Strategy for Offline/Online data synchronization

My requirement is I have server J2EE web application and client J2EE web application. Sometimes client can go offline. When client comes online he should be able to synchronize changes to and fro. Also I should be able to control which rows/tables need to be synchronized based on some filters/rules. Is there any existing Java frameworks ...

Are invisible references still a problem in recent JVMs?

I was reading Java Platform Performance and section A.3.3 worried me. I had been working on the assumption that a variable that dropped out of scope would no longer be considered a GC root, but this paper appears to contradict that. Do recent JVMs, in particular Sun's 1.6.0_07 version, still have this limitation? If so, then I have a l...

Image.createImage problem in J2ME

Hi All, I tried this on J2ME try { Image immutableThumb = Image.createImage( temp, 0, temp.length); } catch (Exception ex) { System.out.println(ex); } I hit this error: java.lang.IllegalArgumentException: How do I solve this? ...

Someone knows a mail (SMTP) delivery library for Java?

I'd like to send mail without bothering with the SMTP-Server which is used for delivery. So JavaMail API doesn't work for me because I have to specify a SMTP server to connect to. I'd like the library to find out on its own which SMTP server is responsible for which email address by querying the MX record of the mail address domain. I...

Java: Determine receiving address when receiving with MulticastSocket

Hi, I am using MulticastSocket to receive UDP Multicast packets. How can I determine to which address such a packet was sent? With the methods provided, I am only able to determine the sender address. Of course, I am the one who sets the To-Address when creating the listening socket, but can I really be sure about this? What about broa...

How to test a webapplication?

If I have java-webapp (servlets), what is the best way to create automated tests for this application? Should I start a server? But that is very fragile. Should I call the servlets directly? But how can this be done? I don't know how to create a ServletResponse/ServletRequest. And what is the best way to test the functionality of the w...

auto scolling of JEditorPane

I am using a JEditorPane as an editor to write comments in my application. The content type is set "text/plain". When I am writing text in it and the text fills the available space and I go on typing, the text is not moving upward to show the cursor. So I dont know where I am typing and what I am typing since it would be visible. Could ...

Best practice for handling null strings from database (in Java)

In my database application I sometimes have to deal with null strings in the database. In most cases this is fine, but when it comes do displaying data in a form the Swing components - using JTextField for example - cannot handle null strings. (.setText(null) fails) (EDIT: I just noticed that JTextField actually accepts a null string, b...

One or multiple servlets per webapp?

I know, it depends on the webapp. But in the normal case, what do you do: one servlet, that serves different pages (like an standalone-application with changing content) or for every page a single servlet. Take for instance a blog. There is the start-page with the most recent blog-entries, an article-view for displaying one blog-entry a...

Best way to implement tooltips for JTree?

Hi, since JTree & TreeModel don't provide tooltips straight out-of-the-box, what do you think, what would be the best way to have item-specific tooltips for JTree? Edit: (Answering my own question afterwards.) @Zarkonnen: Thanks for the getTooltipText idea. I found out another (maybe still a bit nicer) way with overriding DefaultTr...

Abort java webapp on startup

My webapp is part of a larger EAR that is deployed into a websphere server. The server hosts number of other apps on the same virtual server. My webapp has some initialisation/health checks in a servletContextListener->contextInitialized method. I want to make the webapp unavailable if initialisation/health checks fail. What is a realiab...

Struts Validation.xml - requiredif problem

hi, I want my validation.xml to only check for a null if certain options are selected from a dropdown. So far I have <field property="empFDServiceStartDate" depends="requiredif, date"> <arg0 key="Service Start date" resource="false"/> <var> <var-name>field[0]</var-name> <var-value>moverCh...

Please recommend a powerful Java based ETL framework...

Looking for the enterprise level, open source :) Java ETL framework. Came across Clover.ETL but want to hear what people think of it... ...

How do I "decompile" Java class files?

On Java performance questions on this site I often see responses from people who have "decompiled" the Java class file to see how the compiler optimizes certain things. What program can I use to decompile a class file? Does you actually get Java code, or is it just JVM assembly code? Thanks! ...

Java O/R layer for SQL server?

I've got a java server (not web based, more like a big, many-threaded standalone application) that needs to talk to a MS SQL Server database. I just worked on a different project that ported a home-grown O/R layer from oracle to SQL Server, and it ran into significant problems because of too many oracle assumptions (locking, mostly). S...

What is a data structure kind of like a hash table, but infrequently-used keys are deleted?

I am looking for a data structure that operates similar to a hash table, but where the table has a size limit. When the number of items in the hash reaches the size limit, a culling function should be called to get rid of the least-retrieved key/value pairs in the table. Here's some pseudocode of what I'm working on: class MyClass { ...

How to parse logs written by multiple threads?

I have an interesting problem and would appreciate your thoughts for the best solution. I need to parse a set of logs. The logs are produced by a multi-threaded program and a single process cycle produces several lines of logs. When parsing these logs I need to pull out specific pieces of information from each process - naturally this i...

In Java when does a URL connection close?

When does java let go of a connections to a URL? I don't see a close() method on either URL or URLConnection so does it free up the connection as soon as the request finishes? I'm mainly asking to see if I need to do any clean up in an exception handler. try { URL url = new URL("http://foo.bar"); URLConnection conn = url.openConnect...

How to convert a (short) sample in a soundfile to array of bytes

In converting from short to a byte array I found the following solution on the web but could not quite understand the logic involved. //buffer is an array of bytes, bytes[] buffer[position] = (byte)(sample & 0xff); buffer[position+1] = (byte)((sample >> 8) & 0xff); Can someone tell me why 0xff (256) is being anded to the sample which ...

Testing Web Services Consumer

Here are some tools that I have found to test web services consumers: http://www.soapui.org/ https://wsunit.dev.java.net/ Are there any others? I would prefer testing frameworks that are written in Java or Python. ...