java

Multi java processes by jvm ?

Hi, If I want to run several processes in the same jvm without synchronizing (I don't care about multi things running at the same time... I only want to avoid re-instanciating the jvm), what is the best solution ? Starting one thread and joining to wait until it dies, and then creates another thread to do another task ? ...

Exposing Hibernate criteria via service API

This is more of a design than implementation question and it's going to be long so bear with me. It's best explained with an example: Let's say I have a business entity called Product with a bunch of properties (name, price, vendor, etc...). It's represented by an interface (Product) and implementation (ProductImpl, mapped in H...

OutOfMemoryError in j2me application

I'm getting OutOfMemoryError in a j2me application. How can I find what is causing this error? And how to prevent getting this error? EDIT: I make a http request. While the request isn't completed the screen shows a loading image (like a browser shows when a page is loading). This was done by creating an Image and repainting the screen...

How can I require a generic parameter to be an enum that implements an interface?

I'm not 100% convinced that this is a good idea, but I bumped into some code today that's currently implemented as: class MyWidget <T extends Enum<T> > { MyWidget(Map<T, Integer> valueMap) { mValueMap = valueMap; } Map<T, Integer> mValueMap; } where MyWidget then offers methods that use mValueMap to convert the passed-in En...

Strike through java.awt.Font

Is there a way to make a java.awt.Font strike through? ...

Does a 32bit process need more memory when it runs on a 64bit system?

I have a rather memory hungry java application. On my 32 bit systems with Windows XP Professional the application will just run fine if I give it -Xmx1280m. Everything below will end up in an java.lang.OutOfMemoryError: Java heap space exception. If I run the same application on a 64 bit Windows XP Professional (everything else exactly ...

DirectoryDialog in swt does not respect the text field at the bottom of the dialog.

DirectoryDialog in swt has a text field at the bottom labeled Folder: It shows the name of the directory selected in the tree above. However text entered in this field (to change the directory name) is always ignored. Any suggestions to disable this field or make it work so it change the directory name. ...

What pattern for deeply nested web form validation?

I'm refactoring a large legacy web application that has some complicated forms. These forms use javascript to display or hide fields on the basis of other entered fields. E.g ticking a checkbox for "second address" reveals a set of other fields to enter. The current validation for this consists of lots of deeply nested if statements. S...

What is the most used class in Google collections framework?

I wonder what is the most useful class in the Google collections framework? ...

Start using Java out of the box on Mac OS X.

My 10.5.3 install on a MacBook doesn't seem to want to build an example from Sun. It claims it can't find java.io.Console to import. This is annoying to me, and after much searching I can't figure out what I should do to fix it. I have installed the Apple Developer Tools. Here's what happens: macbook:~ dlamblin$ javac RegexTestHarness...

Google App Engine datastore does not support operator +

I'm playing with GAE, and need to make a query with something like this: select from models.Post as p where (p.votesUp + p.votesDown > 10) But I get this error: App Engine datastore does not support operator + Which could be a good approach to replace that query? ...

How do I invoke a Java process from Windows Powershell?

I am having trouble running a Java program with Windows Powershell 2.0. Any help on this would be greatly appreciated. I want the string "Hello World!" to print to the main Powershell console window. Instead, its getting printed to a separate process window that opens then suddenly closes. I don't know exactly how to tell the p...

Trying to track down a memory leak / garbage-collection problem in Java.

This is a problem I have been trying to track down for a couple months now. I have a java app running in that processes xml feeds and stores the result in a database. This has been giving intermittent resource problems that are very difficult to track down. Background: On the production box (where the problem is most noticeable), i do n...

Is there any conflict between NFS and calling getFD().sync()?

My boss is worried that our NFS file system will not be happy with the jboss run java process calling getFD().sync on the files we are writing. We have noticed that frequently the time stamp on the created file is minutes (sometimes as many as 15 minutes) after the log claims the file was finished writing. My only guess is that the NFS...

how to convert a python dict object to a java equivalent object?

I need to convert a python code into an equivalent java code. Python makes life very easy for the developers by providing lots of shortcut functionalities. But now I need to migrate the same to Java. I was wondering what will the equivalent of dict objects in java? I have tried using HashMap but life is hell. For starters consider this, ...

How to use JodaTime with java.sql.Timestamp

I Have a prepared statement INSERT INTO mst(time) VALUES (?); where time is of type Timestamp in a PostgreSQL database. I am inserting a Joda DateTime object, or I should say I am trying to. I can find no way to convert the DateTime ovject into a java.sql.Timestamp. I have read the Joda docs and see no reference to this. Thanks. ...

java creating byte array whose size is represented by a long

Hi all, I'm trying to create a byte array whose size is of type long. For example, think of it as: long x = _________; byte[] b = new byte[x]; Apparently you can only specify an int for the size of a byte array. Before anyone asks why I would need a byte array so large, I'll say I need to encapsulate data of message formats that I ...

How to convert hex string to float in Java?

How to convert hexadecimal string to single precision floating point in Java? For example, how to implement: float f = HexStringToFloat("BF800000"); // f should now contain -1.0 I ask this because I have tried: float f = (float)(-1.0); String s = String.format("%08x", Float.floatToRawIntBits(f)); f = Float.intBitsToFloat(Integer.valu...

Using Scanner.next() to get text input

Hi, I am trying to get text input from the keyboard in Java 6. I am new to the language and whenever i run the following code, I get this error: package test1; import java.util.Scanner; public class Test { public static void main(String[] args) { boolean quit = false; while (!quit){ Scanner keyIn; String c = "x"; while (c != "y...

Extensible GUI framework for Java

I'm a fan of swing and find it has done everything I need except for extensible GUIs. I can make small parts extensible programmatically, but if I want to plug in an optional feature it can be quite tedious to dynamically generate every component being altered. The short period I spent writing a Firefox plug in got me very interested i...