java

Which open-source Python or Java library provides an easy way to draw circles on a ESRI Shapefile?

I need to write a software that creates an shapefile with various circles or circumferences on it. The shapefile created should be readable by ESRI ArcMap. I need a library that let me add circles or circular arc to it. The library could be in for Python or in Java. ...

GWT: Gotcha's

My team is embarking on its very first GWT project. We are fairly strong with Swing applications, with almost all of our work involving significant Swing GUIs. However, this is our very first foray away from the Desktop and to the Web, and the project requires us to use GWT. The project itself is pretty straight forward, the only unknow...

HashCode vs SHA-1

Hi.. I'd like to compare some large objects representing trees and cache something to avoid comparing each time the new object with one already existing... The question is what would be the best something ? (a compromise between performance and collisions...). On the one hand, I have a regular hashCode function based on the value of v...

iterator for replacing list members in Java?

Hmmm... the Java Iterator<T> has a remove() method but not a replace(T replacement) method. Is there an efficient way to replace selected items in a List? I can use a for-loop to call get(i) and set(i) which is fine for ArrayList, but would suck for a linked list. ...

Spring MVC - Form Mapping

Probably missing something completely obvious here, but here goes. I'm starting out with Spring MVC. I have a form controller to process inbound requests to /share/edit.html. When I hit this url from my browser, I get the following error: The requested resource (/inbox/share/share/edit) is not available. Here is my applicationCont...

Programmatic way to place a website into a new Word file... in Java

Is it possible to programmatically place the contents of a web page into a Word file? To further complicate this, I'd like to do these steps in Java (using JNI if I must). Here are the steps I want to do programmatically, followed by ways that I would do this manually today: Provide a method with a URL (Manually: Open page in Fir...

"standard" Java DateBuilder implementation?

I'd like to know if there is a "standard" Java implementation of a DateBuilder before I build one myself. I have looked in the java API and Apache Commons and can't seem to find reference to one. I am looking for something simple that would implement an interface like: Date date = new DateBuilder().month(2).year(1).build(); where da...

jUnit - How to assert that inherited methods are invoked?

Let's say you have some 3rd-party library class that you want to extend, simply to add convenience methods to it (so you can call an inherited method with default parameters for example). Using jUnit/jMock, is it possible to write an assertion / mock expection that tests that the correct inherited method is called? For example, somethi...

Java Web Application File Loader w/ change detection

Is there any tool/framework available to load and autommatically reload an arbitrary file from within a java web application? (I'd like to avoid writing it myself - I do know how to write it) ...

Which method does Set.removeAll() use underneath: equals or compareTo?

Consider the code: class A { private int i; boolean equals( Object t) { if (this == t) return true; if (!( t instanceof A)) return false; if (this.i == t.i); } } Map<String,A> orig; Map<String,B> dup; I am trying to do this orig.entrySet().removeAll(dup.entrySet()); I see that the equ...

GWT 1.6.4 on FreeBSD?

Anyone have GWT 1.6.4 running on FreeBSD? Our build server is a FreeBSD box, and dies with the following when we try to compile: # An unexpected error has been detected by Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x0000000800d0c724, pid=4749[thread 34370233088 also had an error], tid=0xa02d80 # # Java VM: Diablo Java HotSpot...

Auto generate key on JDBC insert in SQL Server

Is there a general, cross RDMS, way I can have a key auto generated on a JDBC insert? For example if I have a table with a primary key, id, and an int value: create table test ( id int not null, myNum int null ) and do an insert PreparedStatement statement = connection.prepareStatement("insert into test(myNum) values(?)", Statem...

What is the best way to create a smooth notification window in Java?

...similar to those produced by email clients like thunderbird or outlook, sliding up or fading in from the tray. ...

Java ResultSet getString weirdness?!

This one has me stumped. I've got a java.sql.ResultSet and I'm pulling string values out of it like so: address.setAddressLine1(rs.getString("AddressLine1")); address.setAddressLine2(rs.getString("AddressLine2")); When I debug and inspect rs.getString("AddressLine1"), the debugger says I've got a 30 character string: "ATTN: ACCOUNTS ...

.Net client vs Java Server with raw data

I am writting a .Net/C# client to a Java Server on Solaris. The Java server is writting Raw byte data in a Gziped format which I need to extract, but I am having trouble to read the data in the right buffer sizes. I read the message not-deterministicly incomplete or complete and can not read the second message in any case. I am reading ...

Parsing RTF Documents with Java/JavaCC

Is anybody familiar with the the RTF document format and parsing using any Java libaries. The standard way people have done this is by using the RTFEditorKit in the JDK Swing API: Swing RTFEditorKit API but it isn't that accurate when it comes to parsing RTF documents. In fact there's a comment in the API: The RTF support was not...

Best way to show the user full name in a JSP header file with a spring/struts framework?

I have a JSP struts application that uses Spring to integrate with the services/dao/database. Basically, struts uses spring to get the data from the DB, it builds the form and forward them to the JSP files. I have a header file that is injected in each JSP file using Tiles. I would like to show "Welcome John Doe" on each page inside th...

Using Jettison to go from JSON to DOM in Java

So far, this is the story of a failure, and any advice is welcome. I tried the following: XMLStreamReader to Document using JAXP with Saxon The code: JSONObject obj = new JSONObject("{\"alice\":{\"bob\": \"a\"}}"); AbstractXMLStreamReader reader = new MappedXMLStreamReader(obj); StAXSource source = new StAXSource(reader); Document do...

How do I use logback-access in combination with Tomcat 5.5?

I've got several Web apps running on a Tomcat 5.5 server, and I'm working on improving/updating the overall logging system used throughout the system. I already had some success with logback-classic. However, when I try to use logback-access (i.e. access the lbAccessStatus servlet), I get this exception: exception javax.servlet.Servle...

Problem configuring Spring's MailSender for our SMTP-server (but GMail works)

Hi, I have some problems sending mails through SMTP using Spring's MailSender interface and the concrete implementation JavaMailSenderImpl. I'm able to send mail through GMail, but not through our company SMTP-server (Postfix). Correct configurations To see that I have the correct configuration I used the excellent mail sender ssmtp. I...