java

How to ignore a type with XStream?

Hello, with XStream, how can I ignore the serialization of a defined Type (for instance, when serializing a GUI, i want to ignore all swing types)? Or if i want to ignore all javax.* types? Thanks in advance, Burkhard ...

Accessing Windows Mobile device Storage Card from Java?

Hi guys, I'd like to be able to access the contents of my Storage Card which is in my Windows Mobile device. Normally, I'd just remove the card and shove it in a card reader, but its encrypted (and thus, locked to my WM device). Is there an API or some sort of framework allowing read/write access to the Storage Card (while PDA is docked...

when I use nio, serverSocket.accept() throws IllegalBlockingModeException

When I code like this: ServerSocketChannel ssc = ServerSocketChannel.open(); InetSocketAddress sa = new InetSocketAddress("localhost",8888); ssc.socket().bind(sa); ssc.configureBlocking(false); ssc.socket().accept(); the ServerSocket.accept() method throws java.nio.channels.IllegalBlockingModeException. Why can't I call accept(), e...

How do I activate JButton ActionListener inside code (unit testing purposes)?

Hi, I need to activate a JButton ActionListener within a JDialog so I can do some unit testing using JUnit. Basically I have this: public class MyDialog extends JDialog { public static int APPLY_OPTION= 1; protected int buttonpressed; protected JButton okButton; public MyDialog(Frame f) { super(f); okButt...

Set the execution directory in Eclipse?

Hello, Is it possible, to execute a class in a specified directory? I mean, a.class is in directory abc and i want it to be executed as if it were in directory xyz. ...

Handle Swing events in JUnit test

I have Swing java application with network communications to several "Players" that are represented as player objects, each with their own communication thread. The app has a "Team" object managing all player objects. Several UI components listen to events passed from the players through the Team object. In my design, the team object f...

Is there a multiple input JOptionPane in Java?

Hey all, I was wondering if there is a JOptionPane where you can get multiple inputs from a user instead of just one? If not, how could i accomplish this using some type of prompt. I am creating Battleship, and wanted to prompt the user to specify locations to place each ship. Thanks, Tomek ...

How to use connection pool with java,MySQL and Tomcat 6

How can I use Connection pool in Java+MySQL+Tomcat 6? I've read this article http://dev.mysql.com/tech-resources/articles/connection_pooling_with_connectorj.html but it is still not quite clear for me. Where do I use the Connector/J? Do I put it in a static variable? Do I use a SessionListener? Does it need any configuration? Thank ...

Representing overloaded methods in UML

I am attempting to create a UML diagram representative of some Java code. In a class I have a method that is overloaded. As far as I know, parameters for methods aren't shown in UML diagrams. How do I represent method overloading in UML? Thanks. ...

What is the difference between Eclipse and Netbeans if I want to use only the Java in it?

I recently got a Dell XPS 64-bit Vista for myself. Eclipse doesn't have their 64-bit version, but I've read on forums that they download Eclipse and work with Java 1.5 on the Vista with only some problems. I have Java 1.6 and Netbeans was easily downloadable. What's the basic/big difference that I'll notice if I shift to Netbeans from E...

Is this broken double checked locking?

Checkstyle reports this code as "The double-checked locking idiom is broken", but I don't think that my code actually is affected by the problems with double-checked locking. The code is supposed to create a row in a database if a row with that id doesn't exist. It runs in a multi-threaded environment and I want to avoid the primary-key...

Difference between selectitem and selectitems tags

What is the difference between the selectitem and selectitems tags in jsf? ...

Java Statistics Package? (Markov Chains and advanced distributions)

Hi guys, I'm having trouble searching for a decent Java library that provides Markov chains, and other advanced distributions (as in, statistics). I've found http://sourceforge.net/projects/hydra-mcmc/ on source forge, and it looks somewhat useable, but does anyone know / use a more up-to-date package? (Haven't really have a trove thr...

Why is itemStateChanged on JComboBox is called twice when changed?

I'm using a JComboBox with an ItemListener on it. When the value is changed, the itemStateChanged event is called twice. The first call, the ItemEvent is showing the original item selected. On the second time, it is showing the item that has been just selected by the user. Here's some tester code: public Tester(){ JComboBox box = n...

How do I create a schedule for n-pastors visiting n-churches?

I want to make a schedule for many pastors. The conditions are: Every month, each pastor must must go to another church, The pastor must not go to same church where he came In 1 year he must go to 12 different churches There is 13 churches and 13 pastors and every church accepts only 1 pastor every month I can't use random(1 to 12) ...

Comparing Infinities in Java

What does the following expression return in Java? Math.max(Float.POSITIVE_INFINITY, Double.POSITIVE_INFINITY); I saw this question in a website and the answer is Double.POSITIVE_INFINITY. I'm not sure about this answer as how can we compare 2 infinities? Can someone clarify this? Thanks. ...

Java webservices client slow when compared to dotnet client

we have DotNet webservice which is being called by two clients , one a dotnet client and other a javaclient The problem is java client is taking longer time in processing the results when compared to dotnet client and affecting the performance greatly , i'm using axis in java Is there any know issue with axis regarding my situation her...

Is running tests with JUnit 3.x vs JUnit 4.x still a best practice?

I haven't looked at this in a while, but if I recall correctly both ant and maven still rely on JUnit 3 for unit tests (as of maven 2.09 the default POM file still has JUnit 3.81). Does it still make sense to stick to JUnit 3 instead of using the latest and greatest? Any good reason I might be missing? ...

BlackBerry - How to add content to the Home Screen?

In the Windows Mobile world you can create a so-called Today plugin that adds content to the phone's main screen -- the one where you see the number of missed calls, unread sms and upcoming events. Is it possible to do something similar on the BlackBerry? I'd like to show some important info there, so that they are as visible and as ea...

How do I get user information within a stateless session bean

I'm working on an existing j2ee app and am required to remove some vendor specific method calls from the code. The daos behind a session facade make calls into the ejb container to get the user's id and password - in order to connect to the database. The user id and password part of the initialContext used to connect to the server. I ...