java

Performance of java on different hardware?

In another SO question I asked why my java programs run faster on AMD than on Intel machines. But it seems that I'm the only one who has observed this. Now I would like to invite you to share the numbers of your local java performance with the SO community. I observed a big performance difference when watching the startup of JBoss on di...

Using JAXB to unmarshal/marshal a List<String>

I'm trying to create a very simple REST server. I just have a test method that will return a List of Strings. Here's the code: @GET @Path("/test2") public List test2(){ List list=new Vector(); list.add("a"); list.add("b"); return list; } It gives the following error: SEVERE: A message body writer for Java type, ...

Hibernate "IN" clause as ALL instead of ANY

I'd like to start by apologizing for my unfamiliarity with Hibernate. I'm only recently getting into it and am far from an expert. I have three tables: Contract, Products, and a link table between them to define a many to many relationship. I'm trying to write an HQL query to return all contracts that contain a range of products. Un...

Animated line graphs with primitive line graphic functions Java

In the effort to learn more about applets and Java, I am experimenting making wave applets by drawing lines (drawLine) and making animated line graphs. I can make a static graph just fine. However I am struggling with the animated aspect of the graph: the axes of the graph should move from left to right, increasing and growing larger th...

What is Sun's attitude towards Clojure?

What is their official position towards clojure? ...

"Key-Value Coding" for Java

In Objective-C on Apple there is something called "Key-Value Coding" that allows you to traverse the object graph using strings similar to filesystem paths. There's an informal protocol (i.e. interface) that allows objects to return values based on the "key" they're asked for. e.g. The default is to return the value of a field named by...

java compiler oddity: field declared in same class, yet "not visible"

The eclipse compiler refuses to compile the following code, stating that the field s is not visible. (IBM's Aspect J compiler also refuses, stating that "s could not be resolved") Why is that? public class Test { String s; void foo(Object o) { String os = getClass().cast(o).s; } } The Java Language Specification ...

Interacting with SVN from appengine

I've got a couple of projects where it would be useful to be able to interact with an SVN server from appengine. Pull specific files from the svn (fairly easy, since there is a web interface which I can grab the data off automatically, but how do I authenticate) Commit changes to the svn (this is the really hard/important part) Possibl...

How do you call a java program from a COBOL on iSeries V5R4

I am tasked with programming a routine that will run on a iSeries platform - where I pass in a parm (like userid, timestamp, etc...) into a program that can perform SHA-2 data encryption. I take the encryption result and format it into a string to open a browser. I know how to open a browser using a CLP but trying to find a way to pe...

setVisibile(false) not hiding the frame

Instead it just opens the new frame, and when that one closes.. it not only doesnt hide and go back to the main frame as its supposed to.. it opens a second version of the first frame... public class FreelanceBillingUI extends javax.swing.JFrame { public FreelanceBillingUI(){ initComponents(); } /** This method is called from wi...

Getting pixel data from an image using java.

I'm trying to get the pixel rgb values from a 64 x 48 bit image. I get some values but nowhere near the 3072 (= 64 x 48) values that I'm expecting. I also get: Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Coordinate out of bounds! at sun.awt.image.ByteInterleavedRaster.getDataElements(ByteInterleavedRaster.java:3...

Is there anything wrong with having a (custom) getId method on a Java object used in JRuby?

I'm a big fan of concise method names, so when our codebase has something like: Account.getAccountId(); I like to add an alias so that I can just do: Account.getId(); However, I've heard ... murmurs from elsewhere in my company about how this might be problematic, because the getId I define will interfere with a built-in getId that...

How do I unlock an Oracle user's account from Java?

I'm trying to figure out why my application is unable to unlock a user's Oracle account successfully. Here's a snippet from my code: OracleDataSource ods = new oracle.jdbc.pool.OracleDataSource(); Properties props = new Properties(); props.put("user", "sys"); props.put("password", "sys"); props.put("internal_logon", "sysdba"); ods.set...

Java TokenField like Cocoa's?

Does anyone know of an existing Java component that implements a TokenField, similar to Cocoa's NSTokenField? An overview of the Cocoa control is at: http://developer.apple.com/mac/library/documentation/Cocoa/Conceptual/TokenField%5FGuide/Introduction/Introduction.html Suggestions for implementation? Thanks! ...

Adding global error on any field error in struts2

I am using Struts2 and a bunch of Validation with Annotations. How do I add a global error message as well on top of field validation errors. Thanks, Fedor ...

How to retry function request after a certain time

How do I make it retry the send attempt if user data is null. Max 2 retries, 1 retry after 10 seconds? public class UserHandler { private List users = new ArrayList(); public void addUser(username) {} //adds user public Userdata findUser(username) {} //finds user public void sendTo(String username, String message) { Userdata ...

Java recursion and Merge Sort

Hi y'all, I'm trying to write a simple merge sort program in Java, I'm seeing a lot of red in Eclipse. I'm still a beginner, and don't quite see whats wrong. thanks. -Kyle public class merge{ public static int[] mergeSub(int[] array, int left, int right){ if(left<right) { int mid = (left+right)/2; int[] a = ...

JDBC, MySQL: getting back row data from PreparedStatement executes.

I'm using the following setup: public MySQLProcessWriter(Connection con) throws SQLException { String returnNames[] = {"processId","length","vertices"}; addresser = con.prepareStatement("INSERT INTO addressbook (length, vertices, activity) VALUES (?, ?, ?)", returnNames); } processId corresponds to an auto-incrementing column in th...

Freeing java file handles

We have a rather large and complex application written in Java which is running on top of the Gridgain package. The problem I am having is that this application will sit there processing requests for approximately a day before every request starts resulting in an exception of type java.nio.channels.ClosedByInterruptException. My suppos...

How to make a first row selected on default while loading the search page in JSP?

When i search some details in the search column and it lists the details for the same below. I want the first row to be selected on default while loading hte search results ...