java

HTTP Connection Pooling in GlassFish

In my webservice, I need to place some HTTP calls. Is it possible to do some connection pooling, like I do JDBC connection pooling? In the Admin Console of GlassFish I see the configuration items Connector Connection Pool and Connector Resources. Can I use these? ...

What's causing my java.net.SocketException: Connection reset?

We are seeing frequent java.net.SocketException: Connection reset errors in our logs for a component that calls a third party Web service that sends SMS messages. Our application is written in Java and is sat on top of Tomcat 5.5. It was written by contractors who are no longer with us. The current team has no real Java expertise, and w...

What is the best IntelliJ IDEA plugin?

I like the Regex and SQL plugins. Which are your favorite ones? ...

How to get some interactivity with a JTable.

Hi, I Have a JTable where the data model contains information from a sql query. Want to get the added ability to take me to a new jpanel by double-clicking a row in the jtabel. Thnx ...

What is the easiest way to iterate over all the key/value pairs of a java.util.Map in Java 5 and higher?

What is the easiest way to iterate over all the key/value pairs of a java.util.Map in Java 5 and higher? ...

How to get the selected node in the package explorer from an Eclipse plugin

I'm writing an Eclipse command plugin and want to retrieve the currently selected node in the package explorer view. I want to be able to get the absolute filepath, where the selected node resides on the filesystem (i.e. c:\eclipse\test.html), from the returned result. How do I do this ? ...

Accessing Windows Registry

I need to access Windows registry from Java.. Also I need to copy some registry entries and may have to enter new registry variables using Java.. some one help me please... ...

A Java Server side (Jsp, velocity, whatever) Calendar component?

Do you know of a Java Server side calendar component. Not a date picker, but a way to display months or weeks as in google calendar with events from my db. ...

What reasons have people had to write their own classloader

I was recently asked in an interview about the order in which classloaders are called when a class is loaded. Unfortunately I've never had the need to write my own classloader so at the time was unfamiliar with the intricacies of classloading. This got me wondering, what reasons are their to write your own classloader. So that's my qu...

How do I get my Threads to not block one another?

I have 2 Threads, one that's polling a mailbox for messages then sleeping while (!quit) and another that's supposed to change the quit flag should the user enter 'Q'. It seems that the scanning Thread blocks the other Thread from executing until there's some input (usually 2 lines). I've tried changing the priority of the Threads and the...

Where do you put your dictionary data?

Let's say I have a set of Countries in my application. I expect this data to change but not very often. In other words, I do not look at this set as an operational data (I would not provide CRUD operations for Country, for example). That said I have to store this data somewhere. I see two ways to do that: Database driven. Create and p...

Does between in HQL compare strictly or not?

if I write in HQL A between 5 and 10 is that equivalent to A >= 5 and A <= 10 or A > 5 and A < 10 or some other of the 4 combinations? ...

Why do my Swing application windows intermittently not close when the application exits?

Why are my Swing applications not closing when using Netbeans 6.5 on Ubuntu 8.10 with Sun JDK 6. Even the Netbeans tutorials downloaded from the Netbeans website do the same. When I close the application I'm left with a dead window. I then have to manually kill the process. It comes and goes, but I can't figure out what triggers this beh...

Where can I find a list of all HQL keywords?

Where can I find a list of all HQL keywords? ...

log4j extra logging arguments

I'm developing a (internal) library where I want to enforce that developers using this lihrary include a text ID when logging error or fatal level messages. Without modifying log4j, what we want to enforce is similar to: logger.error( "E1234:An error has occured" ); With none or minor extension to log4j we could either, during nightly ...

Read pdf uploadstream one page at a time with java

I am trying to read a pdf document in a j2ee application. For a webapplication I have to store pdf documents on disk. To make searching easy I want to make a reverse index of the text inside the document; if it is OCR. With the PDFbox library its possible to create a pdfDocument object wich contains an entire pdf file. However to pres...

Finding prime numbers with the Sieve of Eratosthenes (Originally: Is there a better way to prepare this array?)

Note: Version 2, below, uses the Sieve of Eratosthenes. There are several answers that helped with what I originally asked. I have chosen the Sieve of Eratosthenes method, implemented it, and changed the question title and tags appropriately. Thanks to everyone who helped! Introduction I wrote this fancy little method that generates...

Why is super.super.method(); not allowed in Java?

I read this question and thought that would easily be solved (not that it isn't solvable without) if one could write: @Override public String toString() { return super.super.toString(); } I'm not sure if it is useful in many cases, but I wonder why it isn't and if something like this exists in other languages. What do you guys t...

What are some tips for processing large files in Java

I need to perform a simple grep and other manipulations on large files in Java. I am not that familiar with the Java NIO utilities, but I am assuming that is what I need to use. What resources or helpful tips do you have for reading/writing large files. Also, I am working on a SWT application and need to display parts of that data wit...

Why does an SWT Composite sometimes require a call to resize() to layout correctly?

Sometimes we encounter an SWT composite that absolutely refuses to lay itself out correctly. Often we encounter this when we have called dispose on a composite, and then replaced it with another; although it does not seem to be strictly limited to this case. When we run into this problem, about 50% of the time, we can call pack() and l...