java

What do these HPROF errors mean?

I'm seeing the following errors in my console logs: HPROF ERROR: unable to resolve a method id HPROF ERROR: got NULL trace in obj_alloc HPROF ERROR: duplicate obj_id in object_alloc HPROF ERROR: unable to resolve a method id HPROF ERROR: got NULL trace in obj_alloc HPROF ERROR: unable to resolve a method id HPROF ERROR: got NULL trace i...

Merge properties into a ResourceBundle from System.getProperties()

Hello honorable forum, I'm building a ResourceBundle from a file, this bundle holds < String, String> values. InputStream in = getClass().getResourceAsStream("SQL.properties"); properties = new PropertyResourceBundle(in); in.close(); I would like to add/replace on this bundle some properties that I'm passing from the command line usi...

Can Guice initialize beans?

I've used Spring before (and like it), but thought I'd take a look at Guice. Is there a way to initialize something like maps or lists into beans using Guice? For instance, I've done the following before in Spring to inject a list of items I want to process into some bean. <property name="FilesToProcess"> <list> <value>file1....

Java: Reading the Trailing New Line from a Text File

How can you get the contents of a text file while preserving whether or not it has a newline at the end of the file? Using this technique, it is impossible to tell if the file ends in a newline: BufferedReader reader = new BufferedReader(new FileReader(fromFile)); StringBuilder contents = new StringBuilder(); String line = null; while...

Is there a worst case implementation of the JVM?

The Java memory model makes it clear what can and cannot be assumed about how threads interact through memory. For example, if one thread writes a new value to a field without appropriate synchronization then the new value is not guaranteed to be observable by other threads. In practice, however, other threads might anyhow read the new v...

How to get SQL from Hibernate Criteria API (*not* for logging)

Hi, is there an easy way to get the (to-be-generated) sql from a Hibernate Criteria? Ideally I would have something like: Criteria criteria = session.createCriteria(Operator.class); ... build up the criteria ... ... and then do something like ... String sql = criteria.toSql() (But this of course does not exist) The idea would then...

Java equivalent to WPF

DUPE: http://stackoverflow.com/questions/285147/what-is-javas-answer-to-wpf Is there an Java equivalent to the WPF platform? ...

Powermock Slows Down Test Startup on Eclipse/Fedora 10 when on NTFS partition

I've just started having a proper play with Powermock and noticed that it slows down test startup immensely. A quick look at top while it was running shows that mount.nfts-3g was taking up most of the CPU. I moved Eclipse and my source directory to ext3 partitions to see if that was a problem and the tests now startup quicker but there...

Best Practice for including 3rd party jars in a core library?

We have a core library that we include as a JAR with all of our web applications to maximize code reuse. Now we'd like to include some functionality through this core library via a 3rd party library (iText). Adding the iText JAR to the core library doesn't work because nested JARs aren't found by the classloader. We don't want to add t...

is there a way to combine xpath and regexp to extract parts of a node value?

this is what I want... Assuming I'm trying to get at the value of 'B' <tree> <nodea> <nodeb> A=foo; B=bar; C=goo; </nodeb> </nodea> </tree> the following is magical syntax which would make sense... I'm looking for something comparable that actually works :) string = "./nodea/nodeb/[ REGEX( 'B=(.*?);' ) ]/ $1" Is there anything lik...

In Java, is it ever a bad idea to make an object's members publicly available?

I have a data class in my application. My application will never be used as a public API and I will be the only person developing code within my project. I am trying to save every ounce of processor and memory power I can. Is it a bad idea to make my data members in my data class to have public/protected/default protection so that...

Alphabetically Sort a Java Collection based upon the 'toString' value of its member items.

Assume I have a user defined Java class called Foo such as: public class Foo { private String aField; @Override public String toString() { return aField; } } and a Collection such as: List<Foo> aList; What I am looking to do is to sort the List alphabetically based upon each member's returned '.toString(...

Java Applet - MVC - How to bind model to view?

What's the easiest way to build an applet that has a view with components that are bound to model data and update when the model is updated? Ideally as little code as possible, preferable none/declarative :) If a component type is needed for explanation, please consider a JLabel whose text is bound to a bean with a String getText() acc...

Is anyone using Scala in anger (and what advice for a Java programmer)?

I've been a Java programmer for over 10 years since starting off with Smalltalk. It's my opinion that next big languages are likely to be ones which run on the ubiquitous Java Virtual Machine. I'd like to take advantages of some of the features that Scala (among other languages) has - case statements for class hierarchies, closures, type...

Endless loop in a servlet - recovery possible?

Today I fixed a bug in an application that might have lead to an endless loop in a servlet request/response cycle. So just out of curiousity: What happens, if my servlet actually gets trapped in a for(;;) loop? Is it somehow possible to recover? Will tomcat detect this? Can this instance be killed without restarting the server? Or is ...

Spring framework - class loader relationship

Hello I am having a problem which is probably related to the Spring / class loader relationship. I will apologise for the verbosity of the question now. I have a number of legacy java applications which were originally written and intended to run within a dedicated JVM. We decided upon examination of the resource usage that efficienci...

Diagnosing and improving performance of a java jnlp compared to jar file

Customer X has asked for ways to improve the startup time of a Java process he uses. The problem is, it is not run through a jar file, but rather 'jnlp' (which I am assuming indicates it is a java webstart application) StartUserWorx.jnlp Is there a way to convert this to a JAR file and then have the user invoke the application locally...

Java for C# developers

What is the fastest-track set of resources for a C# developer wishing to hit the ground running in an enterprise-class Java team? ...

Drawing a Translucent .png in AWT

I'm trying to draw a transparent.png image over a TV signal (so blending before rendering is kinda out). When I was drawing a transparent rect, I could just set SrcOver and specify an alpha for my background color and it would work: ((DVBGraphics) g).setDVBComposite(DVBAlphaComposite.SrcOver); But now I'm actually trying to use a png...

Eclipse RCP: Making use of configuration directory

Hello, My Eclipse RCP application requires a configuration file that contains some information to connect to a remote database. Where is the best location to store this configuration file? Can I use the default configuration directory (where 'config.ini' is usually stored) for this purpose? If so, how can I get a File instance to thi...