java

Ant OS-specific copy task

I have an Ant script that performs a copy operation using the copy task. It was written for Windows and has a hardcoded C:\ path as the todir argument. I see the exec task has an OS argument, is there a similar way to branch a copy based on OS? ...

JSF selectItem label formatting

Trying to keep all the presentation stuff in the xhtml on this project and I need to format some values in a selectItem tag have a BigDecimal value and need to make it look like currency. Is there anyway to apply a <f:convertNumber pattern="$#,##0.00"/> Inside a <f:selectItem> tag? Any way to do this or a work around that doesn't involv...

How do I correctly access static member classes?

I have two classes, and want to include a static instance of one class inside the other and access the static fields from the second class via the first. This is so I can have non-identical instances with the same name. Class A { public static package1.Foo foo; } Class B { public static package2.Foo foo; } //package1 F...

A static analysis project/product with rules for enforcing Effective Java advice?

Does there exist a project or product that implements static analysis rules specifically designed to enforce the advice given in "Effective Java," 2nd ed., Bloch? Many people agree that "Effective Java" is a very good book. The ability to scan code for opportunities to apply the "Effective Java" advice would most likely be seen as valua...

Is the Contains Method in java.lang.String Case-sensitive?

Say I have 2 strings, String s1 = "AbBaCca"; String s2 = "bac"; I want to preform a check returning that s2 is contained within s1. I can do this with: return s1.contains(s2); I am pretty sure that contains() is case sensitive, however I can't determine this for sure from reading the documentation. If it is then I suppose my best m...

Why would a "java.net.ConnectException: Connection timed out" exception occur when URL is up?

I'm getting a ConnectException: Connection timed out with some frequency from my code. The URL I am trying to hit is up. The same code works for some users, but not others. It seems like once one user starts to get this exception they continue to get the exception. Here is the stack trace: java.net.ConnectException: Connection timed...

Log4j: Why is the root logger collecting all log types regardless the configuration?

I am having problem that even though I specify the level to ERROR in the root tag, the specified appender logs all levels (debug, info, warn) to the file regardless the settings. I am not a log4j expert so any help is appreciated. Here is a bit more info on the subject: I have checked the classpath for log4j.properties (there is none)...

Creating a fluid panel in GWT to fill the page?

I would like a panel in GWT to fill the page without actually having to set the size. Is there a way to do this? Currently I have the following: public class Main implements EntryPoint { public void onModuleLoad() { HorizontalSplitPanel split = new HorizontalSplitPanel(); //split.setSize("250px", "500px"); sp...

Where to find Java 6 JSSE/JCE Source Code?

Where can I download the JSSE and JCE source code for the latest release of Java? The source build available at https://jdk6.dev.java.net/ does not include the javax.crypto (JCE) packages nor the com.sun.net.ssl.internal (JSSE) packages. Not being able to debug these classes makes solving SSL issues incredibly difficult. Thanks. ...

Color reduction (in Java)

Hi! I would like to find a way to take JPEG (or GIF/PNG) images and reduce the amount of colors to e.g. 20. Could someone recommend some library or other reference? Also source codes in other languages are welcome. ...

Sequence Diagram Reverse Engineering

Hi - I'm looking for a tool that will reverse engineer into a sequence diagram BUT also provides the ability to filter out calls to certain libraries. For example, the Netbeans IDE does a fantastic job of this but it includes all calls to String or Integer which clutter up the diagram to the point it is unusable. Any help is greatly...

How should exceptions be planned at the architectural level?

Are there any good resources for planning how exceptions will be used from an architecture perspective? (Or provide your suggestions directly here.) In projects on which I have worked I find that a few common Exceptions are used over and over again and tend to lose their meaning. From: http://jamesjava.blogspot.com/2007/10/exception-pl...

Is it safe to generally assume that toString() has a low cost?

Do you generally assume that toString() on any given object has a low cost (i.e. for logging)? I do. Is that assumption valid? If it has a high cost should that normally be changed? What are valid reasons to make a toString() method with a high cost? The only time that I get concerned about toString costs is when I know that it is o...

What is the equivalent of Oracle's REF CURSOR in Postgresql when using JDBC?

In Oracle I can declare a reference cursor... TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE; ...and use it to pass a cursor as the return value... FUNCTION end_spool RETURN t_spool AS v_spool t_spool; BEGIN COMMIT; OPEN v_spool FOR SELECT * FROM ...

What's the best way to manipulate Dates and Timestamps in Java?

Every time I need to work with date and/or timstamps in Java I always feel like I'm doing something wrong and spend endless hours trying to find a better way of working with the APIs without having to code my own Date and Time utility classes. Here's a couple of annoying things I just ran into: 0-based months. I realize that best pra...

Advice on handling large data volumes.

So I have a "large" number of "very large" ASCII files of numerical data (gigabytes altogether), and my program will need to process the entirety of it sequentially at least once. Any advice on storing/loading the data? I've thought of converting the files to binary to make them smaller and for faster loading. Should I load everything...

Java jdb remote debugging command line tool

anyone have any experience using this? if so, is it worth while? ...

Does the unmodifiable wrapper for java collections make them thread safe?

I need to make an ArrayList of ArrayLists thread safe. I also cannot have the client making changes to the collection. Will the unmodifiable wrapper make it thread safe or do I need two wrappers on the collection? ...

Finding differences between versions of a Java class file

I am working with a large Java web application from a commercial vendor. I've received a patch from the vendor in the form of a new .class file that is supposed to resolve an issue we're having with the software. In the past, applying patches from this vendor have caused new and completely unrelated problems to arise, so I want to unde...

How to deal with "java.lang.OutOfMemoryError: PermGen space" error

Recently I ran into this error in my web application: java.lang.OutOfMemoryError: PermGen space It's a typical Hibernate/JPA + IceFaces/JSF application running on Tomcat 6 and JDK 1.6. Apparently this can occur after redeploying an application a few times. ...