java

Is there way for a GWT program to tell if it's in hosted or web mode?

I would like my GWT program to be able to determine whether it's in hosted mode or in web mode. Is there a way to do this? Thanks! ...

copy files from one solaris 9 to another using java

How to copy file(s) from one solaris 9 machine to another solaris 9 machine using only java? We have ssh access to both machines. The java program will run on one of those two machines. Update: rsync is not really an option. can't install it easily (UNIX team is, hum, hard to deal with) ...

Java generics - returning subtype of declared type from method

My class is implementing a super-class method which which returns List<JComponent>. The list being returned is read-only: public abstract class SuperClass { public abstract List<JComponent> getComponents(); } In my class, I want to return a field which is declared as List - i.e. a sub-list: public class SubClass extends SuperCla...

Logging in Eclipse/OSGi plugins

I am starting to develop an Eclipse plugin (technically, an OSGi plugin) and one of the first problems I've run into is that I can't seem to control the commons-logging output as I normally would. I've included the commons-logging package in the plugin dependencies, and indeed, when I log something (at INFO or higher severity) it is log...

How do you deal with "super" generics in java?

Take the following generics example import java.util.List; import java.util.ArrayList; public class GenericsTest { private List<Animal> myList; public static void main(String args[]) { new GenericsTest(new ArrayList<Animal>()).add(new Dog()); } public GenericsTest(List<Animal> list) { myList = list; ...

Java: Efficient Equivalent to Removing while Iterating a Collection

Hello everyone. We all know you can't do this: for (Object i : l) if (condition(i)) l.remove(i); ConcurrentModificationException etc... this apparently works sometimes, but not always. Here's some specific code: public static void main(String[] args) { Collection<Integer> l = new ArrayList<Integer>(); for (int i=0; i < 1...

How to generate spectrum color palettes

Is there an easy way to convert between color models in Java (RGB, HSV and Lab). Assuming RGB color model: How do I calculate black body spectrum color palette? I want to use it for a heatmap chart. How about single-wavelength spectrum? Edit: I found that the ColorSpace class can be used for conversions between RGB/CIE and many oth...

Is the Open Source Jalopy Eclipse plugin compatible with Ganymede?

After much searching, I found the download for the eclipse version of jalopy. Is this compatible with Eclipse 3.4? It's dated 2006. I've copied the extracted folder to my plugins directory and run eclipse -clean, but I can't find anything matching 'jalopy' in preferences. If it's not compatible, are there any (free) alternatives? ...

Java EAR File Deployment : Could not find physical destination : null

Anyone know what does this mean exactly? And how to resolve it? ]: Exception in creating message-driven bean container: [com.sun.enterprise.connectors.ConnectorRuntimeException: Could not find physical destination : null]|#] [#|2008-10-22T01:03:08.460+0800|SEVERE|sun-appserver-pe8.2|javax.enterprise.system.container.ejb.mdb|_ThreadID=1...

Cleanest way to toggle a Boolean variable in Java?

Is there a better way to negate a boolean in Java than a simple if-else? if (theBoolean) theBoolean = false; else theBoolean = true; ...

Handling unconventional source directory for a web project in maven

I've inherited a web project (Servlets) which is currently build inside eclipse. I want to add maven around it. But the project's source directory is not following the maven convention. Instead of being inside src/main/java, it's src/package/name/... I don't want to change anything right now because they are working at full speed towar...

No suitable MySQL driver found for JBoss application

Hello, I am new to creating Java web applications and came across this problem when trying to interact with my database (called ccdb) through my application: java.sql.SQLException: No suitable driver found for jdbc:mysql://localhost/ccdb/ My application runs on JBoss and uses Hibernate to interact with the MySQL database. I have the M...

Creating a custom Hibernate UserType - What does isMutable() mean?

I am creating a custom UserType in Hibernate for a project. It has been relatively straightforward until I came to the isMutable method. I am trying to figure out what this method means, contract-wise. Does it mean the class I am creating the UserType for is immutable or does it mean the object that holds a reference to an instance of ...

Deep-Initialising Java Bean properties

Do you bother initialising java bean values? Say, for example: ([g|s]etters omitted) public class SomeClass { private String foo; private Date bar; private Baz someObject; } (Yes, this is a POJO being used as a bean rather than a Java Bean in the strictest sense) In the empty constructor, do you initialise these memb...

Portability of Java Swing applications to OSX

Recently I wrote an extremely basic Java Swing program with a couple of text fields and buttons. The program works fine for me on Ubuntu with Java 1.5. But when I try to run it on OSX (10.4), the main window is displayed correctly but the program seems unresponsive. Nothing seems to happen, no matter which button I click on. I know next...

Double cast for Double smaller than zero

Double out = otherTypes.someMethod(c, c2); assertEquals((Double)-1.0D, out); I get error "Double cannot be resolved" (the Double in assertEquals), is there any way to hack around it except extracting variable? Is this bug in Java or just very usefull feature that wont be fix? ...

Java Iterators

What is an external and internal iterator in Java ? ...

Mocking non-public static methods in abstract classes with JMockit?

I have the following class: public abstract class AbstractParent { static String method() { return "OriginalOutput"; } } I want to mock this method. I decide to use JMockit. So I create a mock class: public class MockParent { static String method() { return "MOCK"; } } And my test code looks like thi...

Java Application Hang on Linux at "java.io.UnixFileSystem.getBooleanAttributes0"

Our customers application seems to hang with the following stack trace: java.lang.Thread.State: RUNNABLE at java.io.UnixFileSystem.getBooleanAttributes0(Native Method) at java.io.UnixFileSystem.getBooleanAttributes(Unknown Source) at java.io.File.isFile(Unknown Source) at org.tmatesoft.svn.core.internal.wc.SVNFileType....

Easy, simple to use LRU cache in java

I know it's simple to implement, but I want to reuse something that already exist. Problem I want to solve is that I load configuration (from XML so I want to cache them) for different pages, roles, ... so the combination of inputs can grow quite much (but in 99% will not). To handle this 1%, I want to have some max number of items in c...