java

Java priority queue

Java's priority queue is a data structure with O(log n) complexity for put (insertion) and O(log n) for poll (retrieval and removal of the min element). C++ STL's multimap has the same functionality but O(1) complexity for retrieval and removal of the min element (begin and erase). Is there an equivalent in Java ? ...

Maven: How to deploy with deploy-file and custom wagon

I'm trying to use a custom maven wagon extension to deploy a jar to my own repository. Can I somehow configure in settings.xml that it recognizes the custom url scheme to be used with the specific wagon or do I have to always modify pom files to contain the wagon extension? There doesn't need to be a base pom or any pom available when...

Producing executable jar in NetBeans

I'm using NetBeans 6.5 and for some reason it won't produce executable jar "out of the box". I set my project to be the main project, defined main class in the project properties "run" menu and it works flawlessly when I press F6 to run it. I looked at the manifest file and it indeed didn't define the main class there, and also omitted...

What are some faster alternatives to Java2d?

I'm looking to do some physics simulations and I need fast rendering in Java. I've run into performance issues with Java2d in the past, so what are the fast alternatives? Is JOGL significantly faster than Java2d? ...

Detecting change in two consecutive pictures

As a toy project i want to write an application that will take pictures from a web cam and then detect changes in them. I want to detect if someone walked in front of the webcam. Can you guys, show me some pointers on how can i detect a major change in two consecutive shots? ...

ConcurrentModificationException and a HashMap

I am persisting objects using JPA. The Main object has an owning One-Many relationship with another object. The other object is stored in a HashMap. What sort of synchronization would fix this problem? It seems to happen at completely random times and is very unpredictable. Here is the exception I get: Exception in thread "pool-1-t...

How do I set the class path on Linux?

I need an answer for the question in the title. Thanks. ...

What's the best way of dealing with AWT Graphics contexts?

Some users of our Swing application have reported weird artefacts appearing on the display. This ranges from components not repainting themselves properly for a second or two, right upto whole portions of the application being repainted like tiled wallpaper over areas of the window. The app has been worked on by developers of all levels...

Using a NamedQuery with a composite class

I have the following class defined in my mapping XML file: <class name="com.data.StateRefData" table="STATE_REF"> <composite-id name="primaryKey" class="com.data.StateRefPkData"> <key-property name="countryCode"> <column name="COUNTRY_CODE" /> </key-property> <key-property name="state"> ...

Hibernate: Identifier

When using Hibernate: Must I identify an id or composite id for each entity, What about if I want to use table without any primary key and without composite key ... Thanx in advance ...

How do I implement maven source dependency among sibling projects?

I have a java project that is composed of 3 sub projects that generate a .jar artifact each (and have sub-dependencies among them). In addition there is a web projects that depends on the first 3 projects and generate a war file. The war file is my final artifact, i.e. what I ship my customers. Additionally I have a parent module that e...

"Fixing" the first few columns in an SWT table to prevent them from scrolling horizontally

We have implemented a table-based editor with an SWT tree table. It pretty much does what we want it to, except that we can't find a way to ensure that the first few columns remain at their position when the user scrolls horizontally (so that one can identify the row being edited). There are a number of third-party table controls in var...

Dumping a java object's properties

Is there a library that will recursively dump/print an objects properties? I'm looking for something similar to the console.dir() function in Firebug. I'm aware of the commons-lang ReflectionToStringBuilder but it does not recurse into an object. I.e., if I run the following: public class ToString { public static void main(String...

Differences between Ant and Maven

Could someone tell me the differences between Ant and Maven? I have never used either. I understand that they are used to automate the building of Java projects, but I do not know where to start from. ...

Should libraries (jar) go into the repository?

Hello, When you start to use a third party library in Java, you add their jars to your project. Do you also add the jars to the repository or do you just keep a local installation. And if the latter, how do you sync between team members to be able to work? Thanks. ...

What is the best java image processing library/approach?

I am using both the JAI media apis and ImageMagick? ImageMagick has some scalability issues and the JNI based JMagick isn't attractive either. JAI has poor quality results when doing resizing operations compared to ImageMagick. Does anyone know of any excellent tools either open source or commercial that are native java and deliver hig...

Bean Scripting Framework

I'd like to use the Bean Scripting Framework to make some of my Java classes be available to users at my company who wish to write scripts + who may be familiar with Javascript or Python (via Jython) or Ruby (via JRuby). I can't really find much tutorial documentation on how to get BSF working... what I would like to do is make a Java a...

Java Threading Tutorial Type Question

I am fairly naive when it comes to the world of Java Threading and Concurrency. I am currently trying to learn. I made a simple example to try to figure out how concurrency works. Here is my code: import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; public class ThreadedService { private ExecutorS...

How should I call a Perl Script in Java?

I read Runtime.getRuntime().exec("perl script.pl") is an option, but is this the best way to do it? I'll need an answer from that script, so I'll have to read the script's return in some cases, although I might read it from a text file on other cases. Anyway, is exec() a good way of calling a Perl Script from Java? I should note, I'm w...

Is it possible for JME app to modify default form on your mobile?

Hi all, I have been asked to find out if its possible to modify the default screen on a mobile phone with jme. Basically the screen that the phone shows when its on but doing nothing but which usually shows the network and nearest tower info. My understanding of JME is that this is not possible. One would have to use symbian for this ...