java

Understanding kernel assigned local addresses on a udp socket

Hi! i'm developing a java application using the jstun library (hxxp://jstun.javawi.de/), and i need to compare my public ip with the one chosen by the kernel (wildcard address - hxxp://java.sun.com/j2se/1.5.0/docs/api/java/net/DatagramSocket.html#DatagramSocket() ) when i create a udp socket. what i don't understand is, if my local ip ...

How can I validate documents against Schematron schemas in Java?

As far as I can tell, JAXP by default supports W3C XML Schema and RelaxNG from Java 6. I can see a few APIs, mostly experimental or incomplete, on the schematron.com links page. Is there an approach on validating schematron in Java that's complete, efficient and can be used with the JAXP API? Thanks ...

Cancelling a long running regex match?

Say I'm running a service where users can submit a regex to search through lots of data. If the user submits a regex that is very slow (ie. takes minutes for Matcher.find() to return), I want a way to cancel that match. The only way I can think of doing this is to have another thread monitor how long a match is taking and use Thread.stop...

How do you associate each Collection's item to another one's?

I have two Collection objects, I want to associate each object of these two in a readable way (HashMap, Object created on purpose, you choose). I was thinking of two loops one nested into the other, but maybe it's a well known problem and has a commonly understandable solution... What if the number of Collection objects raises above tw...

How to debug JNI/C library?

Hi, We have system here that uses Java JNI to call a function in a C library. Everything running on Solaris. I have a problem somewhere with string encoding. An arabic character is returned by the function written in C, but the JNI methods receives a string with another encoding. I already tried setting $NLS_LANG, and the vm parameter ...

Instantiating Oracle Driver results in InvocationTargetException

I have a simple web service that uses an oracle database. When I test the service internally it works fine, however, calling the web service through my client (on the same machine but in a different WAR) throws an invocationtargetexception. I've finally discovered it's an issue with instantiating the OracleDriver. It doesn't throw any...

return generic type from generic function

we have a function more or less like the following. however we currently return List which in function bla() would return List<Bar> at runtime. I'm looking for a way to make both List<Interface> = toubleFuction(foo, bar.getCLass());; and List<Bar> = toubleFuction(foo, bar.getCLass());; possible. basicaly i want it to return List ...

db4o to preserve identity of objects.

Is there a way to preserve an objest identity in db4o. Suppose I store a BigDecimal in embedded db4o. When I read it twice I get two distict objects with the same value (which is quite obvious). Is there any setting to force db4o to cashe query sersults so that two querries would return reference to the same instance, or do I have to ...

How can I find the byte encoding of a TIBCO Rendezvous message?

In my Java application, I am archiving TIBCO RV messages to a file as bytes. I am writing a small utility app that will play the messages back. This way I can just create a TibrvMsg object from the bytes without having to parse the file and construct the object manually. The problem I am having is that I am reading a file that was cre...

Which is the best way to implement SOAP Web Services on JBoss Seam?

I need to implement a SOAP Web Service on Jboss Seam 2.1.0. The idea is to export an Stateless bean method as a Web Service. However, I have found two approaches. First one, is to use the Seam's own web services annotations. The problem of this is the lack of documentation. Second one, is to use Enunciate. It's a lot better document...

Tinyos Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version number in .class file

Hi, When I use make command, like make mica2, in TinyOS. The following problem will occured: Exception in thread "main" java.lang.UnsupportedClassVersionError: Bad version n umber in .class file at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClass(Unknown Source) at java.security.Secure...

Collection Alternative - ConcurrentModificationException

I'm iterating over a JRE Collection which enforces the fail-fast iterator concept. Problem is I need to remove an object's logical partner if the object meets a condition. Thus preventing the partner from also being processed. Can someone suggestion a better collection type for this purpose? Example. myCollection<BusinessObject> for (...

Store class generic in field in Java

Is there any way to store the generic parameter type passed in at construction to a parameter. My goal: class generic<T> { Class<T> type; public generic() { super(); this.type = //Something that gets class from T } } What I'm currently doing is this: class generic<T> { Class<T> type; public generi...

How the attribute field of a HttpServletRequest maps to a raw HTTP request?

In Java, the attribute field of a HttpServletRequest object can be retrieved using the getAttribute method: String myAttribute = request.getAttribute("[parameter name]"); Where the HttpServletRequest attribute data is stored in a raw HTTP request? Is it in the body of the request? For example, I'm trying to create a raw GET HTTP requ...

How do I define my own SelectableChannel?

How would I define a new type of java.nio.channels.SelectableChannel (say for serial ports)? ...

What is the best way to write a test case for RESTLET web services?

I have a JAX-RS web service implemented with Restlet library and now I want to test it. In order to do that I'd like to host this service in my test by preinitializing it with mocked services. What is the best way to host such a service and execute the test calls? @Path("/srv") public class MyService { @GET public void action(@Co...

What is the best way to write a test case for JERSEY web services?

I have a JAX-RS web service implemented with Jersey library and now I want to test it. In order to do that I'd like to host this service in my test by preinitializing it with mocked services. What is the best way to host such a service and execute the test calls? @Path("/srv") public class MyService { @GET public void action(@Con...

How do I handle special characters in a Java PrepareStatement?

In the following SQL query using the PreparedStatement class: String query_descrip = "insert into timitemdescription (itemkey, languageid, longdesc, shortdesc) values (?, 1033, ?,?)"; PreparedStatement pstmt2 = con.prepareStatement(query_descrip); pstmt2.setInt(1, rs4); pstmt2.setString(2, itemdescription); pstmt2.setString(3, itemdesc...

How do I change the background selection color for a jface table

In a elipse-rcp application I am setting the background color for a row in a jface table but I don't want the selection to change this color. I want to be able to specify the color change for a selected row. ...

Java compiler warnings severity

Intro Some continuous-integration tools (say, Hudson) assume compilers generate warnings of different severity (aka priority): high, normal and low. Depending on number and severity of compiler warnings, the tool can mark a build as unstable. I want my builds unstable if compiler generates high priority warnings. I never seen any high (...