java

Using generic parameters with static compareObject method

I'd like to remove all "unchecked" warnings from this general utility method (part of a larger class with a number of similar methods). In a pinch, I can use @SuppressWarnings("unchecked") but I'm wondering if I can use generics properly to avoid the warning. The method is intended to be allow callers to compare two objects by passing...

Is there any performance reason to declare method parameters final in Java?

Is there any performance reason to declare method parameters final in Java? As in: public void foo(int bar) { ... } Versus: public void foo(final int bar) { ... } Assuming that bar is only read and never modified in foo(). ...

Using Mac OS X Services-menu from a Java/Swing application

I would like to make my Java/Swing application compatible with the Services-menu available on Mac OS X. For example, so that the user could select some text in JTextArea and have it converted into speech by Services -> Speech -> Start Speaking Text. Is there a simple way to achieve that? (The application should still be able to run on pl...

Problem matching Java String against array

I need to see if a string value matches with an object value, but why won't this work? public int countPacks(String flavour) { int counter = 0; for(int index = 0; index < packets.size(); index++) { if (packets.equals(flavour)) { counter ++; } else { System.out.println("Yo...

How to format a duration in java? (e.g format H:MM:SS)

I'd like to format a duration in seconds using a pattern like H:MM:SS. The current utilities in java are designed to format a time but not a duration. ...

Create Annotation instance with defaults, in Java

How can I create an instance of the following annotation (with all fields set to their default value). @Retention( RetentionPolicy.RUNTIME ) public @interface Settings { String a() default "AAA"; String b() default "BBB"; String c() default "CCC"; } I tried new Settings(), but that does ...

Efficient data transfer from Java to C++ on windows

I'm looking to stream lots of data (up to ~1 Gbit) from Java to a C++ application (both on the same machine). I'm currently using a FIFO on Linux but need a Windows solution too. The most cross-platform method seems to be a local socket, but: a) won't I get huge overhead from TCP checksumming and copying to & from kernel space, and b) w...

Save Java2D to SWF (flash)

I'm trying to save the output of an vector image drawin in Java2D to an SWF file. There are great libraries for saving java2D output as things like SVG (BATIK) and PDF(itext) but I can't find one for SWF. Any ideas? ...

Read xlsx file in Java

I need to read a Excel 2007 xlsx file in a java application. Does anyone know of a good api to accomplish this task? Thanks in advance for any advice given. -MrPortico ...

sorting HTML tables with displaytag JSP tab library

Hi, I'm using the JSP displaytag tag lib to create HTML tables. I'd like the user to able to click on a column header in order to sort the data. My JSP code is shown below: <display:table name="tableData" id="stat" sort="page"> <display:column property="name" title="Name" sortable="true"/> <display:column property="age" title="Age"...

Why does Javadoc generate non-compliant XHTML?

I just pasted some generated javadoc into an eclipse project, to discover none of the HTML is compliant. There is even cases of closing tags that were never opened. Is there some way to fix this? Maybe a "be compliant" option... ...

java.net versus java.nio

At what point is it better to switch from java.net to java.nio? .net (not the Microsoft entity) is easier to understand and more familiar, while nio is scalable, and comes with some extra nifty features. Specifically, I need to make a choice for this situation: We have one control center managing hardware at several remote sites (each s...

Difference between a HashMap and a dictionary ADT

What is the difference between a Hash Map and dictionary ADT. And when to prefer one over another. For my programming assignment my instructor has asked to use one of them but I don't see any difference in between both. The program is supposed to work with a huge no. of strings. Any suggestions? ...

Default HashMap probing in Java

What does Java use as a default probing method for HashMap? Is it Linear? Chaining or something else? ...

Canvas3D and Swing

Hi, This question is regarding the performance issue in Mac OS X Canvas3D object is embedded in a JPanel; then the panel is integrated with the rest of the Swing-built application. Within that Canvas I am rendering a simple cube by applying certain transformations. At the initial launch It works fine. But when i try to resize the wind...

Enabling https for Java Webstart

hi, I have a swing application deployed in HTTP Server. Users use the browser to point an URL and install the client using java webstart. Now I need to enable https access to my application deployed on HTTP server. I am using JDK 1.5 as default jdk supported in the jnlp file. For time being I use a self signed certificate to the sign ...

Java Instance Variable Accessibility

What is the difference in the accessibility of the following variables in Java? public class Joe { public int a; protected int b; private int b; int c; } I'm most interested in what the last one is doing. ...

Java Swing GUI theming

Is it possible to develop custom PLAF themes for Swing? I would appreciate constructive suggestions in this topic Thanks ...

Java still relevant for web programming?

These days it seems to be all about .NET. I want to start getting into "enterprisey" development and I thought Java would be a good route to go. But looking at job sites there seems to be 2-3x more .NET jobs as there are Java. Do you think investing my time into .NET would be better than going after Java? Is Java losing ground to .NET? ...

Java Class Accessibility

Slightly related to my other question: What is the difference between the following: private class Joe protected class Joe public class Joe class Joe Once again, the difference between the last 2 is what I'm most interested in. ...