java

Display a javascript/css tooltip within a @For loop with Tapestry 4.0.1

I'm not at all familiar with Tapestry 4.0.1 and need to update a legacy application to display a formatted tooltip for a few links within a @For loop. What is the easiest/best way to go about accomplishing this? Should I be using the @Script component or is there a simpler way? By the way, upgrading to a newer version of Tapestry is ou...

Java 5: java.util.concurrent.FutureTask - Semantics of cancel() and done()

I am currently hunting a nasty bug in a multi-threaded environment using FutureTasks and Executors. The basic idea is this to have a fixed number of threads execute individual FutureTasks that compute a result that is to be displayed in a a table (never mind the GUI aspect here). I have been looking at this for so long, I am beginning ...

JPA-based JUnit Test Best Practices

This is a bit of an odd question, but it has been bothering me for a few months now. I have built a JPA-based web application using Wicket + Hibernate (built with Maven), and want to test the DAO layer directly. I created a specific src/test/resources/META-INF/persistence.xml file that I used for testing, but have been running into confl...

Create a Mac OS X Style Dock Bar in Swing

Hi all, I want to create a Mac OS X style Dock Bar to be placed at the bottom of a JFrame. Does anyone know how I can do this? ...

Java generized class reference

If you have a method with the signature: Class<? extends List<String>> getObjectType() { return ?????; } How do you return a proper generic version of the List class? return List.class; //errors return List<String>.class; //errors return List.class<String>; //errors what is the proper syntax to handle this? ...

Why is the user.dir system property working in Java?

Almost every article I read told me that you can't have chdir in Java. The accepted answer to this question says you can't do it in Java. However, here's some of the stuff I tried : geo@codebox:~$ java -version java version "1.6.0_14" Java(TM) SE Runtime Environment (build 1.6.0_14-b08) Java HotSpot(TM) Client VM (build 14.0-b16, mixe...

Java: cross-platform .flv playback

Hi, I'm looking for a way to playback .flv files using java. This means I will need a ffmpeg lib that is cross-platform. I've been toying with jmf and fobs4jmf, but I cannot playback in linux because I need a native library (maybe fobs4jmf.so?). Is there any java lib that allows me to playback .flv besides fobs4jmf? Or fobs4jmf can be ...

Abstract types in webservice definition (wsdl)

I'm using the framework xFire to publish a webservice in my web application. In this service I use abstract return types in the operations like List<GlobaleType>. The operations concrete return values are ArrayList<SpecialType>. The concrete class SpecialType extends the abstract class GlobaleType. In the generated WSDL document only Gl...

How to programmatically close a JFrame

What's the correct way to get a JFrame to close, the same as if the user had hit the [x] button, or pressed Alt+F4 (on windows)? I have my default close operation set the way I want, via setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); and it does exactly what I want, with the aforementioned controls. This question isn't about that. ...

netbeans and Apache Derby Embedded + spring

Hello good fellas.I'm using netbeans 6.7 on windows.I've been using DerbyClient in my spring test project and i've successfully change the driverClassName from org.apache.derby.jdbc.ClientDriver to org.apache.derby.jdbc.EmbeddedDriver.I was formally browsing through the bd from the service tab of netbeans.Now that i've changed the conne...

Java: Comparing two string arrays and removing elements that exist in both arrays.

Hello all, This is mainly a performance questions. I have a master list of all users existing in a String array AllUids. I also have a list of all end dated users existing in a String array EndUids. I am working in Java and my goal is to remove any users that exist in the end dated array from the master list AllUids. I know PHP has a f...

Need PHP or Java code to use multiple internet connections

I have a machine with Linux CentOS distribution that has more than one internet connection available at the same time. I'm trying to write some PHP code that will do the following: Perform an HTTP request to a specific URL "eg. google.com" but through a specific internet connection. Perform the above for several internet connections a...

Java extension/abstraction/implementation question.

I have three classes (class A, class B, and class C). Class A calls an instance of B and runs start(). Class B extends Thread, so when start() is called, anything in the run() method is executed. In the run() thread, there is an instance of class C. Is there anyway to allow a method in Class C to call a method in Class A, without ins...

Why can we cast a Java interface to *any* non-final class?

import java.util.Collection; public class Test { public static void main(String[] args) { Collection c = null; Test s = null; s = (Test) c; } } In the code sample above, I am casting a collection object to a Test object. (ignoring the null pointer). Test has no relationship to Collection whatsoeve...

What are good methods to perform spreadsheet-like calculations in a programming language?

What's the best way to do spreadsheet-like calculations in a programming language? Example: A multi-user application needs to be available over the web that crunches columns and cells of numbers like a spread-sheet based on user submission. What are the best data structures/ database models/patterns to handle this type of work so that h...

Java: problem loading stylesheet

Problem: I'm trying to load a stylesheet in Java but I get an error stateing it isn't a stylesheet. The Error: ERROR: 'The input document is not a stylesheet (the XSL namespace is not declared in the root element).' FATAL ERROR: 'Could not compile stylesheet' Exception in thread "main" javax.xml.transform.TransformerConfigurationExc...

Simple way to repeat a String in java

I'm looking for a simple commons method or operator that allows me to repeat some String n times. I know I could write this using a for loop, but I wish to avoid for loops whenever necessary and a simple direct method should exist somewhere. String str = "abc"; String repeated = str.repeat(3); repeated.equals("abcabcabc"); Related to...

Junk from vendor libraries flooding log4j

How can I best prevent these libraries from flooding my own apps log4j bus? I do not want to set everything to ERROR, but at this rate the vendor library is flooding up the log file at a rate of about a gig/day. I do not want it to log anything to this file... ...

Code Formatter: cleaning up horribly formatted jsp code

So I am working on a jsp/servlet that came to me and I'm looking at the jsp file and it is just a jungle of jstl tags, java code and html thrown together. At first it looked like someone ran the standard eclipse formatter on it and had the page width set to 40 so alot of stuff is broken up, I tried to format it with a larger page width b...

What does this code do (ever seen an object without a reference variable? how about invoking the object later without the reference variable?)?

EventQueue.invokeLater(new Runnable() { public void run() { ZipTestFrame frame = new ZipTestFrame(); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); } }); ...