java

What does "public Weatherman(Integer... zips) {" mean in java

I am trying to read some Java code from a tutorial, I don't understand the line: public Weatherman(Integer... zips) { I don't understand what the ... represents if it was just (Integer zips) I would understand that there is a variable of class Integer called zips. But the ... are confusing me. ...

interface hunt for something like Appendable or OutputStream

Hmmm. I'm trying to write a class that accepts bytes, and would like to implement a well-known interface for this purpose. java.io.OutputStream is an abstract class, not an interface (why???) and that makes me nervous, as I don't know what the consequences are of extending it. If there are no consequences, it should have been an interfa...

Façade - accept object instance, or individual parameters?

I'm creating a stateless session bean (the façade) which will be used for "managing" a particular entity, let's call it Product. There will be methods to add a new product, update an existing product, get products, etc (I'm using Hibernate for persistence, so I have a "ProductDbManager" bean that the façade will use for DB access). Thi...

Setting Scroll Bar on a JScrollPane

I have this JTextPane (wrapped in a JScrollPane) that is backed by a HTMLEditorKit. The contents of the JTextPane is simple HTML with some images (local files) embedded using img tags. The problem is that when you load the the JTextPane, it takes a split second to load and then it comes up with the scroll bar at the bottom of the page. I...

BeansBinding, JGoodies Binding, JFace, or Glazed Lists?

I started to investigate beans binding and my head is starting to spin. There are so many options, but it's a central design decision that sounds hard to change. I have a set of interrelated POJOs that I want to edit with a GUI. What is my best option for a stable, simple deployment? If there's not one good solution, do these options...

Where to create the AbstractFactory

In abstract factory you declare a type which is responsible for creating objects. This would prevent requiring switch's like this: if( type == ONE ) { doOne(); } else if( type == TWO ) { doTwo(); } etc. Or the same: switch( type ) { case ONE: doOne(); break; case TWO: doTwo(); break; etc.... } In...

Displaying a date with a custom timezone.

Lets say I have a string that represents a date that looks like this: "Wed Jul 08 17:08:48 GMT 2009" So I parse that string into a date object like this: DateFormat formatter = new SimpleDateFormat("EEE MMM dd HH:mm:ss ZZZ yyyy"); Date fromDate = (Date)formatter.parse(fromDateString); That gives me the correct date object. Now I wan...

Tomcat Comets application returns .jsp page instead of weather data

I have implemented the Comets tutorial at http://www.ibm.com/developerworks/web/library/wa-cometjava/#N100CC It seems like I am getting data returned from the server using the Comets technique - i.e. being pushed to the browser. However I am getting the .jsp page that I use to trigger the Comet event returned, rather than the weather da...

Randomly accessing a compressed file without using ZipFile (since ZipFile has a major bug).

I know, I know, who would want to compress or uncompressed large files in java. Completely unreasonable. For the moment suspend disbelief and assume I have a good reason for uncompressing a large zip File. Issue 1: ZipFile has a bug (bug # 6280693), sun has fixed this in java 1.6 (Mustang). The fix isn't isn't helpful as our software ne...

Passing dynamic attributes between JSP tags?

I have a set of JSP tags that use dynamic-attributes to allow for arbitrary HTML attributes to be passed in to them, like this: <%-- tag named a:div --%> <%@ tag dynamic-attributes="attrs" %> <div <c:forEach var="attr" items="${attrs}"> ${attr.key}="${attr.value}"</c:foreach>> </div> I then have another tag that I want to be able to p...

Fix Eclipse java references database corruption?

How do I make eclipse rebuild the database of classes contained within a project or workspace? This is what it uses to make the "References" menu action work, what it uses for the "Add import" dialog, etc. Basically, it's part of the core usefulness of Eclipse. And now, it's only working for maybe 5% of my project. I've run into this pr...

Best IDE for Java Web Development

I've been using NetBeans for the past year creating java web apps. Recently I've begun a project using GWT and I've been using Eclipse. Perhaps it's that I'm accustomed to NetBeans, but Eclipse doesn't appear to be as polished as NetBeans. Am I alone in my experience? A lot of people seem to love Eclipse, but I can't figure out why. ...

Hints for java.lang.String.replace problem?

I would like to replace "." by "," in a String/double that I want to write to a file. Using the following Java code double myDouble = myObject.getDoubleMethod(); // returns 38.1882352941176 System.out.println(myDouble); String myDoubleString = "" + myDouble; System.out.println(myDoubleString); myDoubleString.replace(".", ","); System...

Returning null from native methods using JNI

Hi, I have some native code which returns a jbyteArray (so byte[] on the Java side) and I want to return null. However, I run into problems if I simply return 0 in place of the jbyteArray. Some more information: The main logic is in Java, the native method is used to encode some data into a byte stream. don;t ask.. it has to be done li...

How can I get an int[] out of an Iterator?

I have what amounts to an Iterator<Integer>... actually it's a class Thing that accepts a Visitor<SomeObject> and calls visit() for a subset of the SomeObjects it contains, and I have to implement Visitor<SomeObject> so it does something like this: // somehow get all the Id's from each of the SomeObject that Thing lets me visit public i...

Is it possible to switch Class versions at runtime with Java??

I have a java project I want to create which will be built on top of some vendor APIs. The APIs connect to servers running said vendor's software and perform various actions. I have 2 different versions of the servers supported by 2 different API versions. Any changes to the API's are in internal implementation only. I.E. The classes,...

What is a practical application of Java's compareTo method?

In the Java textbook I'm learning from, it says that this uses "lexicographic ordering" to return an integer. I understand how it works, but what is a specific way this is used in programming? ...

How to differentiate between test and production properties in an application?

We're developing a big J2ee e-sales solution. It's got a lot of integrations: CMS, ERP, Mail server etc. All these systems are divided into test and production environments. We need to deploy our application to our test servers with test configuration and when deployed to our production servers it should use the production configuratio...

How do I have to configure a RMI environment so that I'm able to use it in a "real" network?

Hi there! Because I didn't want to implement a communication protocol for my client-server based application, I implemented a RMI client and a RMI server on both sides for the information exchange between the two components. If I try to use my application by starting the two components on the same machine, everything is working fine. ...

Limited sockets to midp?

It seems to me that there is some kind of limitation in socket creation in MIDP. I need to make lots of connections to a server (none concourrent) and in the forth or fith try my app crashes. It crashes in the simulator and in my real device as well. To isolate any possibility of it being influenced by my code, I isolated the following ...