java

Java equivalent to C#'s TimeSpan

Does Java have a data type that represents a period of time eg 34 seconds, 5 minutes etc. I've seen a few implementations of a TimeSpan that cover a Time period like from the 10th of December to the 11th of December. What I need is something like TimeSpan in C#. ...

Need to convert EPS files to jpg/png in Java

We have a webapp where people can upload various image file types and on the backend we convert them to a standard type (typically png or jpeg). Right now we are using ImageIO to do this. However the new requirement is to be able to support eps files. I haven't found any libraries that support EPS in ImageIO, or much in the way of sup...

Highest Performance Database in Java

I need ideas to implement a (really) high performance in-memory Database/Storage Mechanism in Java. In the range of storing 20,000+ java objects, updated every 5 or so seconds. Some options I am open to: Pure JDBC/database combination JDO JPA/ORM/database combination An Object Database Other Storage Mechanisms What is my best opti...

Writing a CANopen test utility

How do I listen in (preferably using Java) on a small set of well-defined CANopen messages without a commercial CANopen stack? ...

Adding Java packages to GWT

I've tried searching but couldn't come up with a defined way on how to add your own packages to a GWT project. My tree structure looks like this: -com.mycompany -public MyApplication.html MyApplication.gwt.xml -com.mycompany.client MyApp.java -com.mycompany.gui TableLayout.java The answer I've seen out there says to ad...

Re-creating threading and concurrency knowledge in increasingly popular languages

I am primarily a Java developer, and I've been reading a lot of in-depth work on threads and concurrency. Many very smart people (Doug Lea, Brian Goetz, etc) have authored books on these topics and made contributions to new concurrency libraries for Java. As I start to learn more about Python, Ruby, and other languages, I'm wondering: ...

Transforming Point object when using simple-xml

I am serializing a class using simple-xml (http://simple.sourceforge.net/) but when i try to use @Element on a Point object i get an error, how can i transform this Point object? ...

Detect version of Java using JavaScript

Is there a reliable way of detecting what version of Java is installed on the client's machine using JavaScript? ...

How do I assign Enter as the trigger key of all JButtons in my Java application?

I'm writing a Java Swing application using the Metal look-and-feel. Every time there is a JButton in my application the user uses the Tab key to move the focus to the button and then hits the Enter key. Nothing happens! If he hits the Space key the button events are fired. How do I assign the Enter key to trigger the same events as the S...

Java generics: List<Container<?>> = new LinkedList<Container<Double>>() is prohibited?

How come, in Java, I can write List<?> list = new LinkedList<Double>(); but not List<Container<?>> list = new LinkedList<Container<Double>>(); where Container is just something like public class Container<T> { ... } This came up because I have a method that accepts a List<Container<?>>, and I would like to use Arrays.asList to p...

How does Apple's Java 1.6 JVM compare with Sun's?

How different is Apple's 1.6 Java VM from Sun's? Are there any major performance differences? Do they both share any code, or is Apple's built completely independently? I have been amazed with the performance of the 1.6 JVM under Linux and Windows, especially on floating-point calculations (it is basically neck-and-neck with optimized C...

How to Cross-Compile Java Source Code to JavaScript?

Given a set of Java source code files, how can I compile them into one or more JavaScript files that can be used with hand-crafted JavaScript? GWT is one option, but every example I've seen so far is aimed at building fancy websites. The simple use case of just converting Java source to Javascript that can be used together with handcraf...

Reflection runtime performance - Java vs CLR

A related post here pretty much established reflection in Java as a performance hog. Does that apply to the CLR as well? (C#, VB.NET, etc). EDIT: How does the CLR compare to Java when it comes to reflection? Was that ever benchmarked? ...

Where to install local Java libraries by default?

I'm integrating JNI bindings with a C++ library. The library follows the usual conventions: the installation root is /usr/local by default and can be modified with the --prefix argument to ./configure; the .a or .so files go in ${prefix}/lib; etc. The JNI binding produces two new libraries, libfoojni.so (the native part) and libfoo.jar...

What's the proper background process behaviour for a non-GUI Java app?

What's the proper way for a Java command line application to do background work without hogging resources? Should it use sleep() in the loop or is there a more elegant/efficient way? ...

Java sort String array of file names by their extension

I have an array of filenames and need to sort that array by the extensions of the filename. Is there an easy way to do this? ...

Location of 1.5.x JDK source code

I have installed Eclipse 3.3 on Mac OS X and it does not contain the src.zip file I am used to seeing with Windows and Linux installations. Where can I download the complete source code for the Java 1.5 JDK (must be specific versions). I have been able to locate the full source code, however it contained the ungenerated Buffer implemen...

How do you make a class listen for PropertyChangeEvents caused by other classes, but not this class?

As described in another question, I have a set of Model objects and an associated set of Panel objects which allow the user to access the data in the Model objects. The Panels are registered as PropertyChangeListeners for the Models, such that if something else updates a value in a Model, it fires a PropertyChangeEvent, and the Panel re...

JSeparator with Title

Hi Do somebody knows a (free) horizontal JSeparator with a title label? Something like that: --- Title XYZ -------------------- Thank you in advance! Best Regards Thomas ...

junit & java : testing non-public methods

Hi all, I'm new to doing serious unit testing as well as junit. JUnit will only test those methods in my class that are public. How do I do junit testing on the ones that are not (i.e., private, protected)? I can test them by not using junit, but I was wondering what the junit standard method was. Please let me know. Thanks, jbu ...