java

Accelerate 2D images in Java *without* disturbing JMenus

Already implemented performance boosters : - Get compatible image of GraphicsConfiguration to draw on - Enable OpenGL pipeline in 1.5: Not possible due to severe artifacts So far I am fine, the main profiled bottleneck of the program is drawing an image with several thousand tiles. Unfortunately it is not regular, else I simply could se...

Should I expect problems when communicating via RMI between Java5 and Java6?

Basically the subject says it all: We have a couple of components running on Java 5, they're talking to each other via RMI. Should we expect any problems, if we move some of them to Java6? By moving I mean compiling them with -source/target 1.6 and running on a java6 vm. ...

Synchronising twice on the same object?

I was wondering if in Java I would get any odd behaviour if I synchronise twice on the same object? The scenario is as follows pulbic class SillyClassName { object moo; ... public void method1(){ synchronized(moo) { .... method2(); .... } } public void me...

How do I find the DNS servers in Android from a Java program?

The java.net.InetAddress.GetByName(String host) method can only return A records so to lookup other record types I need to be able to send DNS queries using the dnsjava library. However that normally relies on being able to parse /etc/resolv.conf or similar to find the DNS server addresses and that doesn't work on Android. The current ...

UI diagram layout

Wanted to generate a UI diagram (with nice layout) depicting relationships amongst network components. Which is the best Java based API to do such layouts with minimum fuss and light codebase. ...

Refactoring static method / static field for Testing

I have the following legacy code: public class MyLegacyClass { private static final String jndiName = "java:comp/env/jdbc/LegacyDataSource" public static SomeLegacyClass doSomeLegacyStuff(SomeOtherLegacyClass legacyObj) { // do stuff using jndiName } } This class is working in a J2EE-Container. Now I would lik...

NoClassDefFoundError while trying to run my jar with java.exe -jar...what's wrong?

I have an application that I'm trying to wrap into a jar for easier deployment. The application compiles and runs fine (in a Windows cmd window) when run as a set of classes reachable from the CLASSPATH. But when I jar up my classes and try to run it with java 1.6 in the same cmd window, I start getting exceptions: C:\dev\myapp\src\co...

How can I dynamically alter the Java LAF UIDefaults?

I'm working on cusomizing a Swing application by dynamically altering the UIDefaults. The end goal is to alter many of them (colors, fonts, sizes, borders, etc) and save the result on a per user basis. While it may give the application some non-standard looks, the client asketh and the client shall receive. The only problem I'm running ...

Load COM oject from jsp

Hi, I am developing a jsp application. I am forced to load a COM object. Can such a thing can be done? if yes, how?? Many thanks, Ofer ...

Java SE 6 vs. JRE 1.6 vs. JDK 1.6 - What do these mean?

I see many different Java terms floating around. I need to install the JDK 1.6. It was my understanding that Java 6 == Java 1.6. However, when I install Java SE 6, I get a JVM that reports as version 11.0!!!??! Who can solve the madness? ...

Correct approach to Properties.

I am working in Java on a fairly large project. My question is about how to best structure the set of Properties for my application. Approach 1: Have some static Properties object that's accessible by every class. (Disadvantages: then, some classes lose their generality should they be taken out of the context of the application; they...

How to set the working directory for a <junit> task to something other than the basedir?

I have an Ant script with a junit target where I want it to start up the VM with a different working directory than the basedir. How would I do this? Here's a pseudo version of my target. <target name="buildWithClassFiles"> <mkdir dir="${basedir}/UnitTest/junit-reports"/> <junit fork="true" printsummary="yes"> <classpath> <pathe...

Java application failing on special characters.

An application I am working on reads information from files to populate a database. Some of the characters in the files are non-English, for example accented French characters. The application is working fine in Windows but on our Solaris machine it is failing to recognise the special characters and is throwing an exception. For example...

How difficult is it to turn a "Java School" programmer into a C or C++ programmer?

My company, a C++ house, is always looking to hire recent grads. However due to the Java Schools phenomenon, we typically end up interviewing strong Java programmers with maybe a minute smattering of C++. Often the C++ classes don't really prepare students for working in C++. Nevertheless, often these are bright kids, eager to learn and ...

Why is SomeClass<? super T> not equivalent to SomeClass<T> in Java generic types?

I noticed the specificaition for Collections.sort: public static <T> void sort(List<T> list, Comparator<? super T> c) Why is the "? super" necessary here? If ClassB extends ClassA, then wouldn't we have a guarantee that a Comparator<ClassA> would be able to compare two ClassB objects anyway, without the "? super" part? In other word...

is something similar to ServiceLoader in Java 1.5?

Hello i want to discover at runtime classes in the classpath which implements a defined interface. ServiceLoader suits well (i think, i haven't used it), but i need do it in Java 1.5. any ideas? ...

Get Drive Size in Java 5

I want to get the size of a drive (or UNC path pointing to a partition would be nice, but not required), as well as free space for said drive (or UNC path). This doesn't need to work cross platform; only in Windows. I know it's easy to do in Java 6, but that's not an option; I'm stuck with Java 5. I can get the free space available by...

Is it possible to upgrade the DB schema with EJB?

Dear folks, lets say I have an EJB application wich defines some entities and relations among them. I figured the DB schema can easily be created from the entities. So now the app works but after a while a need to change some relations, e.g. a one-to-one needs to become a one-to-many, can I upgrade my DB to do so WITHOUT losing the old ...

Using complex data types from Java in Axis webservice

I am currently developing a Java app which handles a SOAP webservice. The problem lies after I parse the WSDL [the Parser object from Apache Axis does it for me], and I create the call. When I try to invoke it, I have to pass a Object[] to assign the parameters [taken from the Action of the WSDL]. A normal action is easy, but when I ...

EJB3 Business Logic Patterns & Practices

I'm in the process of developing a multi-tiered financial processing application in Java using EJB3 (Hibernate + Glassfish for the app and web services layer, Lift on Glassfish for the web UI) and I'm struggling with the question of where to put my business logic. When this project started, our first notion was to put the bulk of our bu...