java

Include multiple jars with classpathentry

I have an eclipse's .classpath file that looks like this: <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="test"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> <classpat...

Odd generics behaviour of List.toArray(T[])

I came across something very basic but extremely bewildering today. I needed to convert a list to an array. The list contained String instances. Perfect example of using List.toArray(T[]), since I wanted a String[] instance. It would not work, however, without explicitly casting the result to String[]. As a test scenario, I used the fo...

print spaces with String.format()

how I can rewrite this: for (int i = 0; i < numberOfSpaces; i++) { System.out.print(" "); } using String.format()? PS I'm pretty sure that this is possible but the javadoc is a bit confusing. ...

Guice configuration error

I'm trying to use Google Guice with the @Inject and @Singleton properties as follows: I have: A Module with an empty configure() method. An interface IFoo A class Foo (implementing IFoo), annotated with @Singleton, with a parameter-less constructor annotated with @Inject. This is the single annotated constructor. The classes, constr...

Wsdl4j vs. WSDLImporter

Do you know of any comparison made for comparing WSDL4J WSDLReader class against the .NET solution (e.g., WSDLImporter)? ...

Side effect--what's this?

Hi, Could anyone tell me the meaning of side effect in the following line: If you're calling an EL function that doesn't return anything, then you're calling it just for its side effects. many thanks in advance. ...

How to convert int[] into List<Integer> in Java?

How do I convert int[] into List<Integer> in Java? Of course, I'm interested in any other answer than doing it in a loop, item by item. But if there's no other answer, I'll pick that one as the best to show the fact that this functionality is not part of Java. ...

Format XML with JAXB during unmarshal

Hi there, I want to format a XML document during unmarshal with JAXB. Unmarshal looks like: Unmarshaller u = createAndsetUpUnmarshaller(enableValidation, evtHandler, clazz); return u.unmarshal(new ByteArrayInputStream(stringSource.getBytes())); While marshaling one can format the code via: marshaller.setProperty(Marshaller.JAXB_FORM...

Construct a java.util.List from a java.util.Set in Scala

I would like to create a java List based on another java Collection eg. Set in Scala. Why is this not possible? I get a required: scala.this.Int error. val in: java.util.Set[String] = new java.util.HashSet() val out : java.util.List[String] = new java.util.ArrayList(in) This worked however, but doesn't feel right: val in: java.util....

Hibernate Error: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session

I have two user Objects and while I try to save the object using sessio.save(userObj) I am getting the following error : Caused by: org.hibernate.NonUniqueObjectException: a different object with the same identifier value was already associated with the session: [com.pojo.rtrequests.User#com.pojo.rtrequests.User@d079b40b] I am cre...

Using a 'lib' directory with intellj IDEA (v6)

I've got an Ant task (using the maven task) set up to automatically download all my Java apps dependencies and consolidate them into a lib directory, but I cant see a way to tell IntelliJ to basically treat everything in that dir as an external lib - I have to manually add them all to my project. This rather defeats the object of automa...

Problems with authentication of a Facebook-application in Java

I'm using Struts2 and Java to create an iFrame Facebook-application utilizing the Facebook-Java-Api in version 2.1.0. Unfortunately, and not surprisingly, I have encountered some issues regarding the authentication. Every request to the application is intercepted by a filter. My plan is to take care of the authentication part in the fil...

Getting IO exception for a missing resource

I am testing my code with a negative test case i.e I have removed one of the keys from the property file. In this case the code is suppose to give a missing resource message(Looger msg given in the catch block of Missing Resource excpetion),but instead it is giving a message from IO exception's catch block and the message is "IO Exceptio...

Recommended way to deploy a WAR on JBoss AS 4.2.3

What is the best way to deploy a WAR on JBoss AS 4.2.3 from a remote location. I don't want to mess something if e.g. my connection hangs while uploading the file. ...

Is there any Java function or util class which does rounding this way: func(3/2) = 2?

Is there any Java function or util class which does rounding this way: func(3/2) = 2 Math.ceil() doesn't help, which by name should have done so. I am aware of BigDecimal, but don't need it. ...

Truncate an array without copying it?

In Java, is there a way to truncate an array without having to make a copy of it? The common idiom is Arrays.copyOf(foo, n) (where the new array is n elements long). I don't think there is an alternative, but I'm curious as to whether there is a better approach. ...

how to validate dynamic map elements

i have a map and i want to validate in struts 2 validation framework by using expression validation how can i access the elements of the map dynamically? if Map myMap; how can i validate the map with dynamic key? if mymap has static key like "Salary", i could validate like <field name="myMap['Salary']"> <field-validator type="reg...

Why does Java have both checked and unchecked exceptions?

Possible Duplicate: When to choose checked and unchecked exceptions Why does Java as a language have both checked and unchecked exceptions. What purpose do they serve? Note: I'm not asking when I should use them, or how to code them, but what they add to the language. ...

Cross-platform source control?

We're doing development for both .NET (Using VS 2008) and Java (using eclipse) Currently, we're using CVS, but there isn't really a good plugin for Visual Studio 2008, so I'm looking at changing to something that has better support for VS 2008 and Eclipse. My initial thought was SVN, as it is really close to CVS, but I'm a bit tempted ...

osgi: fragment is not working outside eclipse pde (and no error appeared)

Context of this problem: OSGi and Eclipse Platform. I've got bundle (plugin) which is host for some fragment. Fragment is running only when I start it through Eclipse "run configuration" (I add it in plugin dependencies in run configuration of plugin), but when I am trying to export it either through eclipse or through maven tycho proje...