java

Mathematica's "Disable Dynamic" dialog kills Java

I use Mathematica with JLink for a research project, which involves a lot of computation. Mathematica is used as a graphical frontend for entering the parameters, and later plotting the results. The actual algorithms are located in Java Classes, which are called via JLink. The "link" is an instance named evalFrontend. On the press of a ...

With facelets what is the equivalent to fmt:formatDate?

I am converting a JSP web page to facelets view handler. What is the equivalent to fmt:formatDate etc.? I know that it isn't supported. But is there an alternative? A third level implementation? ...

Why it is not possible to create a generic fill method in Java?

I have the following classes: abstract class DTO{ } class SubscriptionDTO extends DTO { } and the following generic method: protected void fillList(ResultSet rs, ArrayList<? extends DTO> l) throws BusinessLayerException { SubscriptionDTO bs; try { while (rs.next()){ //initialize bs object... l.add(bs); //compiler error h...

Java RTSP client/server library

Hi. Is anyone aware about good RTSP client/server Java library? Search on Google reveals JMF, which is very outdated. Thanks. ...

generic interface: list of something specific

I want to define an interface MyList which is a list of interface MyThing. Part of the semantics of MyList is that its operations don't have any meaning on objects which do not implement the MyThing interface. Is this the right declaration? interface MyList<E extends MyThing> extends List<E> { ... } edit: (part 2) Now I have another...

designing Java interfaces with ordinary-sounding names, that "play nicely" with other packages.

I'd like to define an interface called Tag in a Java package I am working on, but am hesitant to use such an ordinary-sounding name because of the collision issue. (e.g. you can import only one class or interface with a particular name; if there are more than one that share the same name, you can use import for one of them, but the rest ...

when to use Set vs. Collection?

Is there any practical difference between a Set and Collection in Java, besides the fact that a Collection can include the same element twice? They have the same methods. (For example, does Set give me more options to use libraries which accept Sets but not Collections?) edit: I can think of at least 5 different situations to judge thi...

How can I get the database name I am connected to through Hibernate?

I am trying to get the name of the database I am connected to in SQL Server. I tried doing: Query query = session.createQuery("SELECT db_name()"); List<String> dbNames = query.list(); However, I got the following error: [ERROR PARSER:35] *** ERROR: <AST>:0:0: unexpected end of subtree Exception in thread "main" java.lang.IllegalState...

EJB3 Query + in clause

I need to use an IN clause like the following SQL SELECT * FROM tableA WHERE colA in (1, 2,3) How can i do this in EJBQL? i've tryed the following, which obviously failed: SELECT tab FROM tableA tab WHERE tab.colA in (:colValues) then in java i did query.setParameter("colValues","1,2,3") that gives me the following exception ...

Transitioning from Castor to JPA

I am trying to make my java application more standards compliant and one of the biggest issues i am facing is transitioning our ORM framework from Castor JDO to a JPA implementation (thinking either Hibernate or DataNucleus). We have our own persistent data abstraction layer so the basic refactoring can easily be done by adding a JPA imp...

Parser, Generator for Java with the following requirements...

I am looking for a parser generator for Java that does the following: My language project is pretty simple and only contains a small set of tokens. Output in pure READABLE Java code so that I can modify it (this why I wouldn't use ANTLR) Mature library, that will run and work with at least Java 1.4 I have looked at the following and t...

Java iterator over an empty collection of a parameterized type

In Java, I need to return an Iterator from my method. My data comes from another object which usually can give me an iterator so I can just return that, but in some circumstances the underlying data is null. For consistency, I want to return an "empty" iterator in that case so my callers don't have to test for null. I wanted to write ...

Representing a text file as single unit in Java, and matching strings in the text

Hello, How can I have a text file (or XML file) represented as a whole string, and search for (or match) a particular string in it? I have created a BufferedReader object: BufferedReader input = new BufferedReader(new FileReader(aFile)); and then I have tried to use the Scanner class with its option to specify different delimiters,...

How to select a file path using regex

I would like like to create a java regular expression that selects everything from file: to the last forward slash (/) in the file path. This is so I can replace it with a different path. <!DOCTYPE "file:C:/Documentum/XML%20Applications/joesdev/goodnews/book.dtd"/> <myBook>cool book</myBook> Does anyone have any ideas? Thanks!! ...

Parsing a WSDL to extract Service / Port elements

I want to automatically process a WSDL file to discover defined Service / Port elements. Is this possible, using Java or some sort of Ant utility? If so, how? ...

Query Mac OS X Spotlight from Java

Related to: Query Windows Search from Java But this time to use OSX's spotlight I would like to consume OSX spotlight service from Java. Is there an API available? Thanks. ...

Modify a .txt file in Java

I have a text file that I want to edit using Java. It has many thousands of lines. I basically want to iterate through the lines and change/edit/delete some text. This will need to happen quite often. From the solutions I saw on other sites, the general approach seems to be: Open the existing file using a BufferedReader Read each l...

Using C# to serialize a Java deserializable object

I have two application that need to talk to each other. App1 needs to be able to serialize an object that App2 can then deserialize. Easily done, right? Here's the problem; App1 is C# based, App2 is Java based. So App1 needs to write out the file in the Java binary file format. How can this be done? The way I see it, I have two options....

How to implement a Map with multiple keys?

Hello! I need a data structure which behaves like a Map, but uses multiple (differently-typed) keys to access its values. (Let's don't be too general, let's say two keys) Keys are guaranteed to be unique. Something like: MyMap<K1,K2,V> ... With methods like: getByKey1(K1 key)... getByKey2(K2 key)... containsKey1(K1 key)... contai...

Proof: why does java.lang.String.hashCode()'s implementation match its documentation?

The JDK documentation for java.lang.String.hashCode() famously says: The hash code for a String object is computed as s[0]*31^(n-1) + s[1]*31^(n-2) + ... + s[n-1] using int arithmetic, where s[i] is the ith character of the string, n is the length of the string, and ^ indicates exponentiation. The standard implementation of ...