java

Is there a PropertyPlaceholderConfigurer-like class for use with Spring that accepts XML?

Spring has a very handy convenience class called PropertyPlaceholderConfigurer, which takes a standard .properties file and injects values from it into your bean.xml config. Does anyone know of a class which does exactly the same thing, and integrates with Spring in the same way, but accepts XML files for the config. Specifically, I'm t...

Documentum 5.3 connecting

Hi, I am new to Documentum. I am creating a stand alone java application that needs to connect to a documentum instance (5.3). How would I go about connecting to the instance? ...

Problem running our client from within Eclipse

Whenever we run our Java client from within Eclipse to contact a server app using RMI, we get an exception: java.io.StreamCorruptedException: invalid type code: 01 This only happens from within Eclipse, nowhere else (IntelliJ, command line, etc.). Does anyone know what's going on? ...

How to modify the header of a HttpUrlConnection

Im trying to improve the Java Html Document a little but i'm running into problems with the HttpUrlConntion. One thing is that some servers block a request if the user agent is a Java VM. Another problem is that the HttpUrlConnection does not set the Referrer or Location header field. Since several sites use these fields to verify that t...

Java Swing: Mouseover text on JComboBox items?

In Swing, is there a way to define mouseover text (or tool tip text) for each item in a JComboBox? ...

JPA: 'SELECT DISTINCT' with BLOB columns

I'm trying to run this JPQL query: SELECT DISTINCT i FROM Table i JOIN i.other o which promptly fails with: "Internal Exception: java.sql.SQLException: Columns of type 'BLOB' may not be used in CREATE INDEX, ORDER BY, GROUP BY, UNION, INTERSECT, EXCEPT or DISTINCT statements because comparisons are not supported for that type." This...

Launch JVM process from a Java application use Runtime.exec ?

I want to be able to launch a Java server process from an existing java application and monitor the stdoutput and stderror and redirect that output to a file. Is the best approach to use 'Runtime.exec' and treat the app like any other OS process or is there something more suited for new JVMs. This is on Java 1.5 ...

Fresh WAS-CE installation gives nothing but "HTTP 400 'bad request'"?

I apologise in advance for something I'm expecting is a horrifyingly noob-question. I decided to try out developing web-applications in Java, using IBM's WAS-CE platform. I've never worked with this platform before, nor any other platforms for running Java web applications (I've been using php for all my web projects). Now, I downloade...

Catching several exceptions and rethrowing a general exception

I'm using reflection to add some data to a private variable inside a class from a third-party library. Along the way there are about four different Exceptions that can be thrown; all of them are related to reflection, and all of them are very unlikely to occur. I'm hardcoding the name of the class and variable involved. I'm unlikely t...

Specifying classpath for classes inside the JAR itself

If I have a class org.foobar.MyClass and want to put it in a JAR file, do I have to put it in the JAR's /org/foobar/ directory, or can I put it in /bin/org/foobar/ and somehow specify /bin/ as classpath inside the JAR itself? ...

Does a running thread in an object prevent it from being garbage collected in java ?

Given the code: new Thread(new BackgroundWorker()).start(); Intuitively it feels like the BackgroundWorker instance should be safe from GC until the thread exits, but is this the case ? And why ? Edit: All this heat is basically generated by me asking at least two different questions in the same post. The question in the title has...

scala -> use .net (linq) and java (various frameworks) in the same program?

Hi, Newbie here...can I write one program which incorporates .NET LINQ and also various Java frameworks in the same scala program? Or when I compile, at that time the decision is made either one or the other, .NET or Java Thanks. ...

Why doesn't java.lang.Number implement Comparable?

Does anyone know why java.lang.Number does not implement Comparable? This means that you cannot sort Numbers with Collections.sort which seems to me a little strange. Post discussion update: Thanks for all the helpful responses. I ended up doing some more research about this topic. The simplest explanation for why java.lang.Number do...

What's the best open-source Java Bayesian spam filter library?

In other answers at Stackoverflow it's been suggested that Weka is good, but there are others (Classifier4j, jBNC, Naiban). Does anyone have actual experience with these? ...

Is there a way to tell Eclipse to "Save all" before building?

Does anyone know if there's a way to get Eclipse to do a "Save all" before building java code? (I don't use the "Build automatically" option, I'm talking when you use "Ctrl+B" to do a build all) I've dug thru the preferences, and can't seem to find anything, so I figured I'd check the hive mind at Stack Overflow just in case. I'm usin...

Casting to Unknown Type When Only Given Class Name as a String of That Type

I currently posses a List of Objects(Using Java 1.3), and let's say that I wanted to cast one of the Objects returned from list.get(i) to a type of which I only know the name of the Class as a String. Essentially, how do I Object o = (classname)list.get(i); where className is a String variable of a className. I thought that I could use...

Reset the Authenticator credentials

We have a static method in a utility class that will download a file from a URL. An authenticator has been set up so that if a username and password is required, the credentials can be retrieved. The problem is that the credentials from the first successful connection are used for every connection afterwords, as long as the credentials...

selectOneRadio with action immediately after click

Hi This should be easy for a pro: I am using JSF/Facelets/Seam and am trying to display radiobuttons. Then, after the user has clicked on one of the buttons, the value should be saved and the user redirected to another page immediately (i.e. with no needed click on a submit button). The radio button works, but not the forwarding. Tha...

When to use Enum or Collection in Java

Under what circumstances is an enum more appropriate than, for example, a Collection that guarantees unique elements (an implementer of java.util.Set, I guess...)? (This is kind of a follow up from my previous question) Thanks! ...

What's the best design pattern for formatting numbers?

I need to write the code that would format the value according to the specified options. Right now there is several formatting options that can be chosen: rounding/truncating the number with the specified precision, added prefix (e.g $) or postfix (e.g. %), grouping thousands (applying commas), adding numeric abbreviations (KMB). So e....