java

any tool for java object to object mapping ?

Friends, I am trying to convert DO to DTO using java and looking for automated tool before start writing my own. I just wanted to know if there any free tool available for the same. ...

How do you create a javax.swing.Timer that fires immediately, then every t milliseconds?

Right now, I have code that looks something like this: Timer timer = new javax.swing.Timer(5000, myActionEvent); According to what I'm seeing (and the Javadocs for the Timer class), the timer will wait 5000 milliseconds (5 seconds), fire the action event, wait 5000 milliseconds, fire again, and so on. However, the behavior that I'm tr...

Does HttpsURLConnection.getOutputStream() retry on connect timeout?

I was having a problem where HttpURLConnection.getOutputStream() took 2-3 seconds. I set the connect timeout using HttpURLConnection.setConnectTimeout, expecting a SocketTimeoutException (wrapped by IOException) to be thrown from getOutputStream(), so I could retry the whole operation on another server. Instead, it just works now. Does ...

Problem submitting struts form

I have a form that has some indexed properties. When i submit this form io get the following error message javax.servlet.ServletException'(2009-09-16 13:14:29.814 GMT): BeanUtils.populate. --- Any ideas what i should be looking for to solve this issue? ...

How do I make HttpURLConnection use a proxy?

If I do this... conn = new URL(urlString).openConnection(); System.out.println("Proxy? " + conn.usingProxy()); it prints Proxy? false The problem is, I am behind a proxy. Where does the JVM get its proxy information from on Windows? How do I set this up? All my other apps seem perfectly happy with my proxy. ...

jaxb - strange problem

Hi, I have a super abstract class: @XmlSeeAlso({AndQuery.class, OrQuery.class, NotQuery.class, PropertyQuery.class, MultiQuery.class}) @XmlRootElement public abstract class Query { This class has a subclass: public abstract class MultiQuery extends Query { and this last super class has also two subclasses: AndQuery and OrQuery an...

How to solve problem regarding PrintServiceLookup.lookupPrintService() in windows .

Following is the code when I run on Linux,detects my printer and gives me print out.but when I run it on windows.It do not detect my printer. printbutton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { DocFlavor docflavor = DocFlavor.INPUT_STREAM.TEXT_PLAIN_UTF_8; ...

What is the proper way of inserting a pipe into a Java Pattern expression?

What is the proper way of inserting a pipe into a Java Pattern expression? I actually want to use a pipe as a delimiter and not the or operator. I.E: "hello|world".split("|"); --> {"hello", "world"} ...

How to reverse System.loadLibrary in Java

I am writing a JNI program and I want to unload the dll after i hava finished using it. What can I do for this purpose? I couldn't find a unloadLibrary() method in the Javadoc. ...

Help returning C array to Java using JNA

I am not too familiar with C, but I need to use a C library in my java code. I have created the DLL and am able to access it just fine, but I am attempting to return an array of ints from the C code to the java code. In C I thought you could simply return a pointer to the array, but it's not working like I expect in my Java code. Here...

Possible to parse a HTML document and build a DOM tree(java)

Is it possible and what tools could be used to parse an html document as a string or from a file and then to construct a DOM tree so that a developer can walk the tree through some API. For example: DomRoot = parse("myhtml.html"); for (tags : DomRoot) { } Note: this is a HTML document not XHtml. ...

Is it possible to avoid temp files when a Java method expects Reader/Writer arguments?

I'm calling a method from an external library with a (simplified) signature like this: public class Alien { // ... public void munge(Reader in, Writer out) { ... } } The method basically reads a String from one stream and writes its results to the other. I have several strings which I need processed by this method, but none of...

On FutureTask, finally and TimeoutExceptions in Java

I'm trying to understand how to ensure that a specific action completes in a certain amount of time. Seems like a simple job for java's new util.concurrent library. However, this task claims a connection to the database and I want to be sure that it properly releases that connection upon timeout. so to call the service: int resultCou...

search and replace DOM elements in Java

I'm looking for a way to write a search and replace method using W3C DOM to update a tree. I've thought about doing a breadth-first search as below, but can't think of how to do the in place replacement? import org.w3c.dom.Node; private Element tree; public void searchReplace(Node x, Node y){ Queue<Node> q = new LinkedList<Node>(...

How to find hashcode validity ?

In our application we generate hashcode from a java object and store it in the database at some level. Now my questions is if somebody generates a number by hand, is there a way i can find out whether it is a valid hashcode created by the JVM from an Object and not manually created by hand. ...

How to convert Rhino-JavaScript arrays to Java-Arrays

I have the following: ScriptEngineManager mgr = new ScriptEngineManager(); ScriptEngine jsEngine = mgr.getEngineByName("JavaScript"); jsEngine.eval("function getArray() {return [1,2,3,4,5];};"); Object result = jsEngine.eval("getArray();"); How can i convert the result object which is of type sun.org.mozilla.javascript.internal.Native...

Automatic Unicode string formatting in Java

I just came across something like this: String sample = "somejunk+%3cfoobar%3e+morestuff"; Printed out, sample looks like this: somejunk+<foobar>+morestuff How does that work? U+003c and U+003e are the Unicode codes for the less than and greater than signs, respectively, which seems like more than a coincidence, but I've never ...

Interfacing R to Java

Is rjava the only way to connect R to Java? I am asking because there is a disclaimer at the end of the web page: This interface uses Java reflection API to find the correct method so it is much slower and may not be right (works for simple examples but may not for more complex ones). For now its use is discouraged in progr...

Why/When ComponentListener.componentShown() get invoked ?

Why this code never prints "Hello2" ? public class Test4 { public static void main(String[] args) { JFrame f = new JFrame(); JPanel p = new JPanel(); f.getContentPane().add(p); JLabel x = new JLabel("Hello"); p.add(x); p.addComponentListener(new ComponentListener() { p...

Develop desktop applications view with HTML, as a web application

Hello I am used to develop web applications in Java (Struts, Spring, JSP...). But now I want to develop a desktop one. I never liked to design windows in Java (AWT, Swing, SWT): too much work for an ugly interface. So I think it could be a good idea if could take advantage of my web-app skills. One option is to modify the SWT Browser an...