java

Generic way to add info to a Throwable without creating a new Throwable

Would it be benefical to add a generic way to add info to a Throwable without creating a new Throwable? I often see code like this: try { foo(); } catch(Exception e) { throw new Exception(e.getMessage() + " extra info=" + blah, e); } Would it be better to instead add Throwable.setProperty(String key, String value) so that the cod...

how to open webdav link with correct program on client?

We have a browser based application which integrates a webdav server. We generate URLs to specific documents on our (webdav) servlet. (https://server.com/webdav/path/to/file.doc) What we are looking for is a good way for our clients to open these links directly in the appropriate program. I.E. for a windows user, "https://server.com/web...

How do you make a Swing/JFace/SWT GUI addressable?

I have a "fat" GUI that it getting fairly complex, and I would like to add links from a place to an other, and add back/forward buttons to ease navigation. It seems to me that this would be easier if my application was addressable: each composite could have its URI, and links would use that URI. Are there design patterns applicable to t...

How do I discover the Quarter of a given Date?

Given a java.util.Date object how do I go about finding what Quarter it's in? Assuming Q1 = Jan Feb Mar, Q2 = Apr, May, Jun, etc. ...

How much null checking is enough?

What are some guidelines for when it is not necessary to check for a null? A lot of the inherited code I've been working on as of late has null-checks ad nauseam. Null checks on trivial functions, null checks on API calls that state non-null returns, etc. In some cases, the null-checks are reasonable, but in many places a null is not a ...

Multithreaded access to file

Hi, We have a multi threaded java program. Multiple-threads will write to a file, and one thread will read from that file. I am looking for some design ideas. Is synchronization necessary? ...

Tomcat VS Jetty

I'm wondering about the downsides of each servers in respect to a production environement. Did anyone have big problems with one of the features? Performance, etc. I also quicky took a look at the new Glassfish, does it match up the simple servlet containers (it seems to have a good management interface at least)? ...

Best way to authenticate users in a web application

I was looking at ways to authenticate users in a web app, but in a way where the main web app doesn't need to process the password. Something like OpenId, but the authentication server would definitely need to be hosted on an intranet, internet services can't be accessed by the application server. My environement is pretty much Java web...

How to backup ArrayList in Java?

I have some data stored as ArrayList. And when I want to backup this data,java bounds two objects forever. Which means when I change values in data ArrayList this changes come to backup. I tried to copy values from data separately to backup in the loop, tried to use method data.clone() — nothing helps. ...

How do I bind an ArrayList to a PreparedStatement in Oracle?

I was wondering if there was a way to bind an ArrayList (or any kind of List, for that matter) to a PreparedStatement which will eventually be used to access an Oracle database. I found: http://stackoverflow.com/questions/178479/alternatives-for-java-sql-preparedstatement-in-clause-issue And that seems similar to my issue, but this qu...

A range intersection algorithm better than O(n)?

Range intersection is a simple, but non-trivial problem. Its has been answered twice already: http://stackoverflow.com/questions/224878/find-number-range-intersection http://stackoverflow.com/questions/143552/comparing-date-ranges The first solutions is O(n) and the second solution is for a database (which is less than O(n) of cours...

Can we use JMX for Alerts/Notification

Here are the specs that I'm trying to implement in a nutshell: 1) Some Alerts have to be sent on certain events in the application. 2) These Alerts have Users subscribe to them. 3) And the Users have set their own Notification preferences (e.g. Email and/or SMS). I have not been able to find an open source solution in Java so far. I...

Calling a JNI modal dialog disables taskbar icon.

In a Java application (JRE 1.5.0_12) on Windows XP, I call a native method: public native int attachImage( ... ); ... which lives in a Visual C++ 6.0 .dll. It displays an application-modal window. Problem is, the application's tray icon doesn't respond to mouseclicks while this window has focus. This is an issue because when this wind...

What are your impressions of Maven?

I am considering using Maven for a Java open source project I manage. In the past, however, Maven has not always had the best reputation. What are your impressions of Maven, at this time? ...

Java: Reading integers from a file into an array.

File fil = new File("Tall.txt"); FileReader inputFil = new FileReader(fil); BufferedReader in = new BufferedReader(inputFil); int [] tall = new int [100]; String s =in.readLine(); while(s!=null) { int i = 0; tall[i] = Integer.parseInt(s); //this is line 19 System.out.println(tall[i]); s = in.readLine(); } in.close(); ...

Where Should I Begin Learning Struts?

I need to use struts for a class I am taking. What is the best web resource to begin looking at how to set up a struts application from scratch? I am already familiar with JSP's. This is for Struts 1 by the way. ...

using Java to get a file's md5 checksum?

I am looking to use java to get the md5 checksum of a file. I was really surprised but I haven't been able to find anything that shows how (and the best way) to get the md5 checksum of a file. Any ideas on how to go forward? Thanks. ...

Setup OpenGL ES for desktop Java

Anyone know if/how to setup OpenGL ES for plain old regular Java on Linux without running it through a cell phone emulator? My goal is to develop tools for building Android games (ex. a map builder). Ideally these would run outside the emulator to take benefit of greater screen real estate, native OS conveniences, fast start time, etc. ...

RECENT Java References?

I'e been programming Java forever, but have been away from it for a while. Can anyone recommend a really good Java reference, where "really good" is defined by "Good coverage of the language, detailed coverage of recent extensions, and written for the technical reader (not a "for Dummies" sort of book)"? ...

Swing app global modal.

Simple question: Can a swing frame be completely modal ( block all others windows ) ? I tried the following, but I can still click on other apps windows ( like this browser ) JDialog myDialog = .... myDialog.setModalityType(Dialog.ModalityType.APPLICATION_MODAL); Plase paste some code if this is possible. Thanks in advance. U...