java

Is mobile OSGi ready for real world usage on mobile phones?

I'm developing applications for mobile devices. I've never developed for OSGi and right now, I'm considering to get started with it. I've read a lot about using OSGi on mobile phones, and it's said to run on J2ME, Symbian, Windows Mobile, Android... But to me it seems as if nobody currently uses it there. I really would like to exploi...

Design Pattern for Java: Does this look familiar to anyone?

In my application, I have the following recurring pattern where I get the feeling that this is an incomplete or warped version of some common pattern that I'm not aware of. In my implementation, I can't seem to find a good way to implement a particular operation, as described below. A collection of objects, let's call them "sources", pr...

url and name spaces java convertion.

I need to be able to convert: (url) http://www.joe90.com/showroom to (namespace) com.joe90.showroom I can do this using tokens etc, and a enforced rule set. However, is there a way (a java package) that will do this for me? or do i need to write one myself? Thanks ...

How to expose HTTP return (error) codes with JMX?

We would like to monitor HTTP error codes (e.g. per minute) for later graphing. How can we expose HTTP return (error) codes with JMX? Are there code samples or have you done something like that? Is this contained in Tomcat per default? About the implementation: Should the code increase a JMX counter and set it to 0 every minute? Th...

Log4j is hanging my application what am I doing wrong?

First some background on the application. I have an application processing many independent tasks in parallel via a thread pool. The thread pool is now hanging. The following is an snippet from my thread dumps, all my Threads in pool-2 are BLOCKED by "pool-2-thread-78". It seems to be locked trying to write to the console which I find e...

Jython Netbeans with JavaSE

Hello everyone, I want to develop a Java application mixing java with jython. I am using the IDE Netbeans with the python plugin. How do i work on this? (There is a built in support for Groovy with javaSE from IDE call Groovy classes from Java code, and Java classes from Groovy code but not for jython) ref: http://www.netbeans.org/fe...

How do i print the columns of a JAMA matrix?

I use the JAMA.matrix package..how do i print the columns of a matrix ...

How can I select the local interface for an EJB?

Say I have the following EJB (using ejb3): @Stateless(name="Queries") @Remote(Queries.class) @Local(Queries.class) public final class QueriesEJB implements Queries { ... } The class is available through both a local and a remote interface. How can I inject the local interface for this EJB in another part of the app? Specifically...

How can I change the color of a particular element of a HTMLDocument in a JEditorPane?

I basically want to implement changing the color of the links when I hover over them. The HyperlinkEvent that is triggered when I mouse over the link hands me the HTML element, but it won't let me set any style attributes on it, and I can't figure out how to get the elements that do have settable attributes. ...

Get the table name from the model in Hibernate

How do I get the table name for a model in Hibernate? Apparently there used to be a getTableName() method in ClassMetadata, but it's been removed. There's a getClassMapping(String entityName) method in Configuration, but I don't know how I can (or if I should) use Configuration from within my DAO implementation. My DAO implementation ...

Creating a process from within an instance of Jetty that was launched from Maven

Hello, I'm looking to launch a separate Java process from within an instance of a Spring controlled bean that runs in a Jetty container. The Jetty instance was launched from mvn jetty:run This separate process communicates with the launching process via RMI and I'd like to be able to maintain a hook to the process's ID or Process objec...

how to compile and run interdependent plugin jars

I have to build two eclipse-plugin projects into two separate jars with each one dependent on the other for compiling. Eclipse IDE complains about "cyclical dependency...". How do I build these plugin jars? I guess running these plugins by just putting them in the eclipse/plugin folder should be smooth. ...

How to open a Windows named pipe from Java?

On our Linux system we use named pipes for interprocess communication (a producer and a consumer). In order to test the consumer (Java) code, I would like to implement (in Java) a dummy producer which writes to a named pipe which is connected to the consumer. Now the test should also work in the Windows development environment. Thus I ...

CPU load from Java

Is there a way to get the current cpu load under Java without using the JNI? ...

How can I make a custom resource also be lookuped in glassfish by the java:com/env-scheme?

I've created some JDBC resources and Custom resources in GlassFish. I named JDBC resource jdbc/mydb and the Custom resource service/test. The JDBC connection is lookedup with the call ic.lookup("java:comp/env/jdbc/mydb"). It can also be found with ic.lookup("jdbc/mydb"), which has some disadvantages, see answer of Robin below. But my ...

About Hibernate save using Dynamic-Map entity mode

In the following example, how can I save the value of role to the role with id=1 without loading it? I have tried: Map user = new HashMap(); user.put("address","Address test"); user.put("role",1); session.save("User",user); But that results in: java.lang.ClassCastException: java.lang.Integer cannot be cast to java.util.Map at o...

How to convert UTF-8 character to ISO Latin 1?

I need to convert a UTF-8 trademark sign to a ISO Latin 1, and save it into database, which is also ISO Latin 1 encoded. How can I do that in java? I've tried something like String s2 = new String(s1.getBytes("ISO-8859-1"), "utf-8"); but it seems not work as I expected. ...

jgoodies bindings + coalescing frequent changes

I have a java app that updates data at a variable rate (received from a fairly high-speed data stream out of my control, but up to 120Kbytes/sec), and I would like to display statistics like the # of bytes/packets received, using a dialog box. I'm looking into JGoodies bindings and got something preliminarily working with artificial dat...

Why does a junit test fail in eclipse but pass from ant?

I have a JUnit test that is checking to make sure that a customized xml serialization is working properly. The customized xml serialization is just a few custom converters for Xstream. The deserializers work, but for some reason in Eclipse 3.x, JUnit fails the serialization. In Ant on the command line, it works just fine. It also wor...

How to get the text content on the swt table with arbitrary controls

I have different controls placed on a table using TableEditor. ... TableItem [] items = table.getItems (); for (int i=0; i<items.length; i++) { TableEditor editor = new TableEditor (table); final Text text1 = new Text (table, SWT.NONE); text1.setText(listSimOnlyComponents.get(i).getName()); text1.setEditable(false); editor.grabHor...