java

Object Conversion Pattern

Hi there. So I have several different objects coming from external sources (unmodifiable) that represent the same concept. For example, Address. I have com.namespace1.Address (with fields houseNum, street, city), com.namespace2.Address (with fields h, s, c), namespace3.com.CoolAddress (with fields house_num, street, citY). The proble...

PHP's strtotime() in Java?

I'm looking for an easy way to generate a MySQL DATETIME from any type of time input a user may enter. PHP makes it easy with its strtotime() function that can do: strtotime(’2004-02-12T15:19:21+00:00′); strtotime(’Thu, 21 Dec 2000 16:01:07 +0200′); strtotime(’Monday, January 1st’); strtotime(’tomorrow’); strtotime(’-1 week 2 days 4...

Fastest way to Convert List<?> to List<ObjectType>

This is a Java question. What is the fastest way to convert a List<?> to a List<ObjectType>? I am aware that this is possible through iteration please exclude that option. Example by iteration, final List<ObjectType> targetList = new ArrayList<ObjectType>(); // API returns List<?> so I have no choice. List<?> resultList = resultSet.ge...

What is the AWT equivalent to JFrame.setDefaultCloseOperation?

We are using the setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE) method of JFrame. I want to support the native look and feel, and thus I have to use AWT instead of Swing. So what is the AWT method equivalent to setDefaultCloseOperation? Am I correct in thinking that in order to support the native look and feel we should use AWT instea...

How can I define static properties for Rhino's ScriptableObject?

Rhino provides Scriptable interface and ScriptableObject helper class to implement a javascript object backed by a java object. When ScriptableObject is constructed, its methods with names starting with jsFunction___, jsStaticFunction___, jsGet___, jsSet___, jsConstructor are automatically defined for the javascript object. This way yo...

Using wildcard for classpath?

G'day everybody, I have been using so many 3rd party libraries(jar files) that my CLASSPATH is completely messed up as i have to include the path for every single jar file that i use. I've been wondering if there is a way to include all the jar files in a folder using wildcard(*) operator (like *.jar). But it seems to be...

Making servlet serve READONLY text/html resource

While i am serving text/html resource resource i want to make it the resource as readonly. And we need to restrict editing the readonly attribute who is downloading the resource ...

Java performance timing library

I frequent wrap code in a System.nanoTime() pair in order to timing it. Something like: long start = System.nanoTime(); methodToBeTimed(); long elapsedTime = System.nanoTime() - start; There is any good timing library that helps with this problem? Also homegrown code will be accepted. NB A profiler is not a solution here, since ...

check file exists java

Hi, i want create text file if file allready exists it should not create new file it should append to next how can i do it in java? for every one second i'm reading data from inputstream when i stop reading and again i start reading data at that time i should write to same file if file allready exist does i have to check the coditi...

How to use JSpeex in java

I want to transmit audio data over network using java program. I got that JSpeex is an external jar which can help me for encoding audio data. But I donot know how to use Speex. Thanks Sunil Kumar Sahoo ...

Why does m2eclipse exclude resources from Eclipse build path?

I am trying out m2eclipse, the Eclipse plugin for Maven, and have noticed that the resources are now excluded from the build path of all my projects. I have seen a question on the M2Eclipse FAQ page which seems to deal with this exact question, but the answer (paraphrased) seems to say that this is intentional to allow resource filterin...

Need a Java map/table with multiple keys to one value. Value is commonly altered

What I need is a collection which allows multiple keys to access a single object. I need to apply frequent alterations to this object. It also must be efficient for 500k+ entries. ...

Websphere slow URLConnection

We have a Websphere version 6.1 deployed on a Linux environment. To open an https connection we call openConnection() and connect() on a java.net.URL object. Opening this connection takes aproximately 3 minutes. Once the connection is established we can write and read data very fast. Using openssl a connectiontest (ssh console) works v...

How to deploy jBPM 3.2.2 console on Oracle 10g iAS

Hi! Does anybody have experience regarding deployment of the jBPM Administration Console on Oracle 10g iAS? I successfully deployed it using an .ear, security mappings working, I can even login to the console, Hibernate finds the JNDI datasource but it cannot find the TransactionManager. I see no log, only the exception thrown in the...

Which current tools and technologies would you suggest as 'state of the art' for a new Java web project?

We are starting a new Java Web project and would like some advice on the 'state of the art' on (free) tools/technologies. Our current shopping list contains: Java 5 JBoss Spring Junit Selenium (automated functional test) Ant Cruise Control (CI) How does it look like? Also, what is the tool of choice for adding some AJAX bits? ...

How to use viewActions with Commands?

Hi, I've learned that actions in Eclipse-RCP should not be used and instead commands should be used. The problem is if I try to use the ExtensionPoint org.eclipse.ui.viewActions(makes little icons on top of views, see Image) only Actions can be defined there. Is there a way to use commands with this ExtensionPoint? If that is no...

Is there any java compression utility

I need to (un)zip some files and after some googling I haven't found any utility for doing it. I know I can do it with built-in java.uitl.zip.* classes but isn't there any utility, that will make it easer, best like this: SomeClass.unzip("file_name.zip", "target_directory"); or SomeClass.zip("source_directory", "target_file_name.zip"...

Drawing a dot grid

I'm new to graphics programming. I'm trying to create a program that allows you to draw directed graphs. For a start I have managed to draw a set of rectangles (representing the nodes) and have made pan and zoom capabilities by overriding the paint method in Java. This all seems to work reasonably well while there aren't too many node...

DB2 Java user defined function

Hello, I'm trying to write a Java function for my DB2 database. When my class is in SQLLIB/Function all is working great. Now i need to change the path of the class to another location for client deployment. I can't seem to make it work. Please Help! Thanks. ...

Is Java's Timer task guarenteed not to run concurrently?

new Timer(...).schedule(task) Is task guaranteed to be run by a single thread at any given time? ...