java

In Java what do arrays inherit from? Can I do this?

Hi Sorry for the newbie question, I'm used to C# so my Java framework knowledge is not so good. I have a couple of arrays: int[] numbers = new int[10]; String[] names = new String[10]; //populate the arrays Now I want to make a generic function which will print out the values in these arrays, something like the following (this shou...

What Java type to use to represent a currency value in a web service?

I'm creating a web service in Java that will be consumed by an external application, probably written in C#. In my Purchase bean, I have a Currency object for the total cost. However, this leads to the following error: Caused by: com.sun.xml.bind.v2.runtime.IllegalAnnotationsException: 1 counts of IllegalAnnotationExceptions java.util...

What is this thread/paint exception about?

I'm playing with things I don't really understand at the moment for a JAVA project on a Robot exploring an unknown territory (a grid of valid positions and blocked positions). Anyway, I tried to improve the basic GUI we were given as an example of how to proceed, it had been done with a text field and various unicode characters to repres...

How can I determine the type of a generic field in Java?

I have been trying to determine the type of a field in a class. I've seen all the introspection methods but haven't quite figured out how to do it. This is going to be used to generate xml/json from a java class. I've looked at a number of the questions here but haven't found exactly what I need. Example: class Person { public fina...

Java TrayIcon message close button

The real question here might be if there's a better way to display desktop messages in Java. However... I'm using the Java trayicon to display messages to a desktop user. Because they want to keep certain messages up until the user clicks on them, in order to use the 'displayMessage' feature, I have to keep displaying them until the u...

Maven Webservice Plugin working with install, not deploy

Hi All, I have a maven module that uses the plugin jaxws-maven-plugin. I have the webservice up and running and when browsing to the .../myWebservice?wsdl, I get the WSDL. No problem. This also works when running the wsimport maven goal through: <plugin>   <groupId>org.codehaus.mojo</groupId>   <artifactId>jaxws-maven-plugin</artifa...

Testing with Thread.sleep

What are the recommended approaches to using Thread.sleep() to speed up tests. I am testing a network library with a retry functionality when connections are dropped or timeout errors occur, etc. The library however, uses a Thread.sleep() between the retries (so it won't connect thousands times while the server is restarting). The cal...

java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration incompatible with org.apache.xerces.xni.parser.XMLParserConfiguration

I get this error when deploying the ear file on to WLS 10.3 on AIX platform. (The same ear works fine on Windows / Linux platforms) Caused by: java.lang.ClassCastException: org.apache.xerces.parsers.XIncludeAwareParserConfiguration incompatible with org.apache.xerces.xni.parser.XMLParserConfiguration at org.apache.xerces.parsers.DOM...

Spring MVC: Resolving the view based on User-Agent

Spring Version: 2.5.6 I want to resolve the view to a specific velocity file based on the value of the User-Agent header. My current line of thinking is an implementation similar to the UrlBasedViewResolver such that the user-agent value is Map'd (via context) to a specific directory(value) based on a matching a regular expression(key)...

Drawing diagonal lines over a textbox in Java

Is it possible to draw diagonal lines over a JTextField (or any other Swing control as well) without just putting a panel over the textbox? ...

Java Inner Class Iterator Problem

I'm having difficulty using an inner Iterator. private List<List<? extends HasWord>> sentences = new ArrayList<List<? extends HasWord>>(); private Iterator<String> wordIterator = new Words(); private class Words implements Iterator<String> { int currSentence = 0; int currWord = 0; @Override public boolean hasNext() { return cur...

Is there a Queue (PriorityQueue) implementation which is also a Set?

I'm looking for a PriorityQueue implementation which is also a Set. The compareTo implementation if its elements must not have the requirement to be consistent with the implementation of equals. Is there somewhere such a implementation for java? Update: I implemented it now using a SortedSet as the internal collection. So I only had t...

Web Service Return Type

Hi! what are the possible return types for a web service? I am using NetBeans 6.7.1 and working in Java. I want to make a web service that would return String[]... I made a class of Authorization and I want to add a function in an already made web service. the problem is that it doesnt let me make an operation of return type string. Any...

Access Mbean from sessionbeans on Glassfish

There are few servers runing simple MBean server listening on specified port. These servers are supposed to be monitored by main server running glassfish with an application based on EJB 3. One of the sessionbeans should perform monitoting by connecting to remote MBean. I use this url service:jmx:rmi:///jndi/rmi://${host}:${port}/jmxr...

Servlet with User Input?

Ok, so a user enters some information on a JSP and clicks 'submit' which launches a servlet. This servlet then processes the information and sends back another JSP. That works fine. However, what about if the servlet needs to ask the user a question before continuing the processing? In a general Java Application you can use the likes of...

Adding WCF Service Reference To Java Application

How can I add WCF Service Reference to my Java Console Application ? I want to use this method for prove the interoperability of my wcf Service. ...

GWT: Timer causes runtime warning.

Hello, I'm working on my first GWT-based Java project for a school assignment. It's a chat application and the client polls the server for new events, while the server keeps an timer for each user to detect inactivity. The following problem occurs at runtime: Dec 8, 2009 7:41:17 PM com.google.apphosting.utils.jetty.JettyLogger warn WA...

Help with writing a void reverse() method and use recursion to reverse a complete sentence(Java).

I already wrote something that removes the first character of a string and puts it after the remaining substring and then prints it out, the instructions were to reverse the sentence using recursion by removing the first letter of the sentence and concatenate it to the reversed remaining substring, ie. "Hello" yields "olleH". But i dont ...

Set the LSB of Java java.awt.Color RGB components

Is there a method for changing the LSB value of java.awt.Color RGB components? ...

Preventing the selection of next cell in JTable while using AutoComplete

Hi, I am using GlazedList's autoComplete support in a JTable using the below code itemColumn.setCellEditor(AutoCompleteSupport.createTableCellEditor(itemList)); How do I prevent the selection or editing the next cell, if the user hasn't selected any value in the CellEditor. ...