java

PrintWriter and PrintStream never throw IOExceptions

Some days ago I realized that PrintWriter (as well as PrintStream) never throw an IOException when writing, flushing or closing. Instead it sets an internal flag (trouble=true) when an error occurs. It's not possible to get the exact exception, but only if there was some exception (checkError()). My question is: why would one want to h...

Cosuming web-service with JAX-WS

I need to be able to read the host name and port from the web.xml file before every call to the ws. So how can I do this in JAX-WS or isn't it possible? ...

What's the best way of reading a sprite sheet in Java?

I'm writing a basic sprite engine for my own amusement and to get better aquainted with Java's 2d API. Currently I am making use of large numbers of separate .png files with transparent backgrounds to represent the various sprites and different frames of animation that I need. Most 'real world' game development projects seem to make use ...

Auto generate data schema from JPA annotated entity classes

I'm using JPA (Hibernate's implementation) to annotate entity classes to persist to a relational database (MySQL or SQL Server). Is there an easy way to auto generate the database schema (table creation scripts) from the annotated classes? I'm still in the prototyping phase and anticipate frequent schema changes. I would like to be able...

Does single-paradigm OOP lead to abstraction inversion?

For those of you who aren't familiar with the concept, abstraction inversion is the implementation of low-level constructs on top of high-level constructs, and is generally considered a bad thing because it adds both needless complexity and needless overhead. Of course, this is a somewhat imprecise, subjective definition. In your opini...

How to call web service with Android

I am having a lot of trouble finding good information on how to call a standard SOAP/WSDL web service with Android. All I've been able to find are either very convoluted documents and references to "kSoap2" and then some bit about parsing it all manually with SAX. ... Ok, that's fine but it's 2008 so I figured there should be some good l...

Find known sub image in larger image

Does anyone know of an algorithm (or search terms / descriptions) to locate a known image within a larger image? e.g. I have an image of a single desktop window containing various buttons and areas (target). I also have code to capture a screen shot of the current desktop. I would like an algorithm that will help me find the target i...

Thread API priority translation to OS thread priority !

How are the java API thread priorities (1-10) gets translated to the OS level priorities since most OS don't have thread priority levels (in terms of number) which match this. So keeping in mind , can there be a scenario when two or more threads with different priorities eventually get the same priority at OS level. Please clarify, if ...

"Always on Top" Windows with Java

In Java, is there a way to have a window that is "Always on top" regardless if the user switches focus to another application? I've searched the web, and all of the solutions lean to some sort of JNI interface with native bindings. Truly this can't be the only way to do it?.. or is it? ...

python (jython) archiving library.

Is there a neat archiving library that automatically handles archiving a folder or directories for you out there? I am using Jython, so Java libs are also open for use. -UPDATE- Also Im looking for timestamp archiving. ie archive-dir/2008/11/16/zipfilebypreference.zip then the next day call it again and it creates another folder. Im s...

Metro - Missing <wsse:Security> in SOAP Header

I am writing a Java console client app for an existing web service with Metro. The classes are generated with wsimport, and I have a small test program that instantiates a service and a port, executes the following code, and calls the service. ((BindingProvider) port).getRequestContext().put( BindingProvider.USERNAME_PROPERTY, "som...

String replace function

hi all, I have following string String str = "replace :) :) with some other string"; And I want to replace first occurance of ':)' with some other string And I used str.replaceFirst(":)","hi"); it gives following exception "Unmatched closing ')'" I tried using replace function but it replaced all occurance of ':)'. ...

Java generics - passing a collection of subtype to a method requiring a collection of base type

How to do this in Java - passing a collection of subtype to a method requiring a collection of base type? The example below gives: The method foo(Map<String,List>) is not applicable for the arguments (Map<String,MyList>) I can implement by creating a class hierarchy for the typed collections - but is it possible otherwise? public vo...

How to call a stored procedure from iReport?

I'm trying to call a stored procedure that receives a parameter from the iReport plugin wizard of Netbeans 6.1, how can I successfully accomplish this task? Other technical details are: using MySQL 5.0.51a-17, and iReport designer 1.0. Thanks! ...

Changing java lookandfeel without modifying the application

Is it possible to change java lookandfeel without modifying the program in a real-world environment? I know that theoretically the answer is yes. I also created demo applications and changed the lookandfeel even at runtime and it worked. But when I created a real application with lots of controls lookandfeel change was not really workin...

tomcat 5.5 - problem with reading resource files

I'm using Tomcat 5.5 as my servlet container. My web application deploys via .jar and has some resource files (textual files with strings and configuration parameters) located under its WEB-INF directory. Tomcat 5.5 runs on ubuntu linux. The resource file is read with a file reader: fr = new FileReader("messages.properties"); The proble...

How to build EAR/WAR for Websphere Application Server by Eclipse?

IBM Rational Application Developer is very slow and has many problems. I tried to use ant scripts to build EAR/WAR files for Websphere Application Server but it did not work. ...

Java: `static` Methods

When I call a static method like: Something.action(); Since a instance isn't created how long will the Class of the static method be held in memory? If I call the same method will the Class be reloaded for each call since no instance exists? And are only individual static methods loaded when called or are all the methods and static ...

Is there an easy to integrate java-based forum software available

Integration via Hibernate, Acegi, Spring, Tiles would be superb. ...

How to detect synchronization violations with Java

Hi, I'm wondering what good ways there would be make assertions about synchronization or something so that I could detect synchronization violations (while testing). That would be used for example for the case that I'd have a class that is not thread-safe and that isn't going to be thread-safe. With some way I would have some assertion...