toJavaArray helper function
function [jxs] = toJavaArray(xs, className)
%TOJAVAARRAY Converts a Matlab vector to a Java array.
%
% Copyright (C) Bayes Server. All rights reserved.
if ~isvector(xs)
error('xs must be a vector')
end
n = length(xs);
if ~exist('className','var')
className = class(xs(1));
end
jxs = javaArray(className, n);
for i = 1:n
jxs(i) = xs(i);
end