java

Problems while submitting a UTF-8 form textarea with JQuery/AJAX

I am having problems submitting forms which contain UTF-8 strings with Ajax. I am developing a Struts web application which runs in a tomcat server. This is the environment i set up to work with UTF-8: I have added to tomcat's conf/server.xml the attributes URIEncoding="UTF-8" useBodyEncodingForURI="true" into the Connector tag. I have...

Java return copy

In Java, say you have a class that wraps an ArrayList (or any collection) of objects. How would you return one of those objects such that the caller will not see any future changes to the object made in the ArrayList? i.e. you want to return a deep copy of the object, but you don't know if it is cloneable. ...

Is there a Java Console/Editor similar to the GroovyConsole?

I'm giving a presentation to a Java User's Group on Groovy and I'm going to be doing some coding during the presentation to show some side-by-side Java/Groovy. I really like the GroovyConsole as it's simple and I can resize the text easily. I'm wondering if there is anything similar for Java? I know I could just use Eclipse but I'd ...

Why won't .NET deserialize my primitive array from a web service?!

Help! I have an Axis web service that is being consumed by a C# application. Everything works great, except that arrays of long values always come across as [0,0,0,0] - the right length, but the values aren't deserialized. I have tried with other primitives (ints, doubles) and the same thing happens. What do I do? I don't want to ch...

How Popular is the Seam Framework

I'm using JBoss Seam Framework, but it's seems to me isn't very popular among java developers. I want to know how many java programmers here are using it, and in what kind of projects. Is as good as django, or RoR? ...

Install-base of Java JRE?

Is there an online resource somewhere that maintains statistics on the install-base of Java including JRE version information? If not, is there any recent report that has some numbers? I'm particularly interested in Windows users, but all other OSs are welcome too. ...

Looking for terracotta examples

I am looking for good example code for terracotta. Especially around using master/worker pattern. In particular using custom routing (we like, but would like to use some strick data affinity type routing - ie. one worker looks after a set of task types ). Also examples or experience setting up masters and topologies would be great als...

experience with java clustering ?

Would like to hear from people about their experience with java clustering (ie. implementing HA solutions). aka . terracotta, jgroups etc. It doesn't have to be web apps. Experience writing custom stand alone servers would be great also. UPDATE - I will be a bit more specific -> not that interested in Web App clustering (unless it ca...

How do I tell Maven to use the latest version of a dependency?

In Maven, dependencies are usually set up like this: <dependency> <groupId>wonderful-inc</groupId> <artifactId>dream-library</artifactId> <version>1.2.3</version> </dependency> Now, if you are working with libraries that have frequent releases, constantly updating the <version> tag can be somewhat annoying. Is there any way to ...

How would you use Java to handle various XML documents?

I'm looking for the best method to parse various XML documents using a Java application. I'm currently doing this with SAX and a custom content handler and it works great - zippy and stable. I've decided to explore the option having the same program, that currently recieves a single format XML document, receive two additional XML docu...

Java code to import CSV into Access

I posted the code below to the Sun developers forum since I thought it was erroring (the true error was before this code was even hit). One of the responses I got said it would not work and to throw it away. But it is actually working. It might not be the best code (I am new to Java) but is there something inherently "wrong" with it? ...

Java Swing: Displaying images from within a Jar

When running a Java app from eclipse my ImageIcon shows up just fine. But after creating a jar the path to the image obviously gets screwed up. Is there a way to extract an image from the jar at runtime so I can then open it up? Or, is there a better way to do this? I'd like to distribute a single jar file if possible. ...

How do you get a reference to the enclosing class from an anonymous inner class in Java?

I'm currently creating an explicit reference to this in the outer class so that I have a name to refer to in the anonymous inner class. Is there a better way to do this? ...

Is Jad the best java decompiler?

It hasn't been updated since 2006. Are there better alternatives? Homepage: http://www.kpdus.com/jad.html ...

Is there a reason to use BufferedReader over InputStreamReader when reading all characters?

I currently use the following function to do a simple HTTP GET. public static String download(String url) throws java.io.IOException { java.io.InputStream s = null; java.io.InputStreamReader r = null; //java.io.BufferedReader b = null; StringBuilder content = new StringBuilder(); try { s = (java.io.InputStrea...

Java: Programatic Way to Determine Current Windows User

I see many similar questions, however I want to find the Username of the currently logged in user using Java. Its probably something like: System.getProperty(current.user); But, I'm not quite sure. ...

Quick way to find a value in HTML (Java)

Using regex, how is the simplest way to fetch a websites HTML and find the value inside this tag (or any attribute's value for that matter): <html> <head> [snip] <meta name="generator" value="thevalue i'm looking for" /> [snip] ...

Detach an entity from JPA/EJB3 persistence context

What would be the easiest way to detach a specific JPA Entity Bean that was acquired through an EntityManager. Alternatively, could I have a query return detached objects in the first place so they would essentially act as 'read only'? The reason why I want to do this is becuase I want to modify the data within the bean - with in my app...

How to fetch HTML in Java

Without the use of any external library, what is the simplest way to fetch a website's HTML content into a String? ...

Design: Java and returning self-reference in setter methods

I have already proposed this in my blog, but I find this place the most appropriate. For classes that have a long list of setters that are used frequently, I found this way very useful (although I have recently read about the Builder pattern in Effective Java that is kinda the same). Basically, all setter methods return the object itsel...