java

Embedded java databases

I would like to get opinions or suggestions regarding embedded databases in Java. In particular I was looking at H2, HSQLDB and Derby. Have you use any of these in a production project? Do you have comment or recommendations to select one over the others? Thanks Edit: I am currently evaluating these options to use in our internal devel...

Using Small (1-10 Items) Instance-Level Collections in Java

While creating classes in Java I often find myself creating instance-level collections that I know ahead of time will be very small - less than 10 items in the collection. But I don't know the number of items ahead of time so I typically opt for a dynamic collection (ArrayList, Vector, etc). class Foo { ArrayList<Bar> bars = new Array...

FTP Timout on NLST when directory is empty

EDIT: Learned that Webmethods actually uses NLST, not LIST, if that matters Our business uses the WebMethods integration server to handle most of our outbound communications, and its FTP functionality leaves something to be desired. We are having a problem that may be specific to WebMethods, but if anyone can point me in a direction of...

How do you "OR" criteria together when using a criteria query with hibernate?

I'm trying to do a basic "OR" on three fields using a hibernate criteria query. Example class Whatever{ string name; string address; string phoneNumber; } I'd like to build a criteria query where my search string could match "name" or "address" or "phoneNumber". ...

Accessing Tomcat Context Path from Servlet

In my Servlet I would like to access the root of the context so that I can do some JavaScript minifying. It would be possible to do the minify as part of the install process but I would like to do it on Servlet startup to reduce the implementation cost. Does anyone know of a method for getting the context directory so that I can load a...

How do I expose data in a JSON format through a web service using Java?

Is there an easy way to return data to web service clients in JSON using java? I'm fine with servlets, spring, etc. ...

What are some good examples of a WS-Eventing client in Java?

There are a few web service frameworks available for Java: Axis2, CXF, JBossWS, and Metro. Does anyone have some good examples of a WS-Eventing client with these frameworks? ...

When can/should you go whole hog with the ORM approach?

It seems to me that introducing an ORM tool is supposed to make your architecture cleaner, but for efficiency I've found myself bypassing it and iterating over a JDBC Result Set on occasion. This leads to an uncoordinated tangle of artifacts instead of a cleaner architecture. Is this because I'm applying the tool in an invalid Context,...

Java: Is there a way to take a screenshot using java and save it to some sort of image?

Simple as the title states: Can you use only Java commands to take a screenshot and save it? Or, do I need to use an OS specific program to take the screenshot and then grab it off the clipboard? ...

Painless resource management in java

In C++ we acquiring a resource in a constructor and release it in a destructor. So when an exception rises in a middle of a function there will be no resource leak or locked mutexes or whatever. AFAIK java classes don't have destructors. So how does one do the resource management in Java. For example: public int foo() { Resou...

Should I learn C# or Java?

Guys, I'm good with VB.Net, I don't see why I should officially learn C#, instead I want to learn Java so I can develop for different platforms. What is your advice? ...

Drilling down in VisualVM

I just installed Java 1.6_07 so I could try profiling with VisualVM. It tells me that my app is spending 60% of its time in sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run How do I find out what it was doing during that time? How much of the time was it waiting for something to call it, or doing something else? What was cal...

JComboBox Selection Change Listener?

I'm trying to get an event to fire whenever a choice is made from a JComboBox. The problem I'm having is that there is no obvious addSelectionListener method. I've tried to use actionPerformed but it never fires. Short of overriding the model for the JComboBox I'm out of ideas. How do I get notified of a selection change on a JComb...

Can I convert the following code to use generics?

I'm converting an application to use Java 1.5 and have found the following method: /** * Compare two Comparables, treat nulls as -infinity. * @param o1 * @param o2 * @return -1 if o1&lt;o2, 0 if o1==o2, 1 if o1&gt;o2 */ protected static int nullCompare(Comparable o1, Comparable o2) { if (o1 == null) { if (o2...

What GUI should I run with JUnit(similar to NUnit gui)

What GUI should use to run my JUnit tests, and how exactly do I do that? My entire background is in .NET, so I'm used to just firing up my NUnit gui and running my unit tests. If the lights are green, I'm clean. Now, I have to write some Java code and want to run something similar using JUnit. The JUnit documentation is nice and clear ...

What platforms JavaFX is/will be supported on?

I have read about JavaFX, and like all new technologies I wanted to get my hands "dirty" with it. However, although it talks of multiplatform support, I can't find specifics on this. What platforms support a JavaFX application? All those with Java SE? ME? Does it depend upon the APIs in JavaFX that I use? ...

What's the difference between the inner workings of Java's JVM and .NET's CLR?

What's the difference between the inner workings of Java's JVM and .NET's CLR? Perhaps a starting point would be, are they basically the same thing in their respective environments (Java > JVM > Machine code) (C# > CLR > IL). Update: Several people have alluded to the points I was trying to cover: Garbage Collection Boxing/Unboxi...

Hibernate - maxElementsOnDisk from EHCache to TreeCache

Hi, I'm migrating a Hibernate application's cache from EHCache to JBoss TreeCache. I'm trying to find how to configure the equivalent to maxElementsOnDisk to limit the cache size on disk, but I couldn't find anything similar to configure in a FileCacheLoader with passivation activated. Thanks ...

HTML to Markdown with Java

is there an easy way to transform HTML into markdown with JAVA? I am currently using the Java MarkdownJ library to transform markdown to html. import com.petebevin.markdown.MarkdownProcessor; ... public static String getHTML(String markdown) { MarkdownProcessor markdown_processor = new MarkdownProcessor(); return markdown_proce...

How do you generate and analyze a thread dump from a running JBoss instance?

How do you generate and analyze a thread dump from a running JBoss instance? ...