java

best java jabber client library

What good/bad experiences do you have with java jabber libraries? ...

MultiThreading and Deadlock

suggest me any real time situations in which i'm supposed to create multiple threads,and then introduce a deadlock situation.this is kind of a project!!! can u ppl help to make the application more interestin with some real time situation... ...

How to create a zip file in Java

I have a dynamic text file that picks content from a database according to the user's query. I have to write this content into a text file and zip it in a folder in a servlet. How should I do this? ...

Priority Queues in Java

java.util.PriorityQueue allows a Comparator to be passed at construction time. When inserting elements, they are ordered according to the priority specified by the comparator. What happens when the priority of an element changes after it has been inserted? When does the PriorityQueue reorder elements? Is it possible to poll an element ...

JAX-WS on JBoss fetches WSDL 3 times ?!?

I'm trying to use JAX-WS on a JSF app on JBoss 4.2.3 and from the logs I notice that for every operation it fetches the WSDL not once, but 3 times: [07/Jul/2009:14:45:52 +0300] "GET /wsdl/my.wsdl " 200 23731 "-" "Java/1.6.0_13" [07/Jul/2009:14:45:52 +0300] "GET /wsdl/my.wsdl " 200 23731 "-" "Java/1.6.0_13" [07/Jul/2009:14:45:...

How can I avoid the general Exception thrown by the Server-class in Jetty?

Jetty can be used as a library to embed a servlet-server into your application. To do that, you create an instance of the class Server and call start at some point. This method throws Exception. Catching or throwing a pure Exception (not a specialized subclass) is bad style. Does anyone know, how I can avoid this and get a Jetty-server i...

Java's equivalent to .Net's AutoResetEvent?

What should I use to get semantics equivalent to AutoResetEvent in Java? (See this question for ManualResetEvent). ...

Protect excel file with java

Is there a way to create open protected excel file in Java? I'm looking at JExcelApi and Apache Poi projects but with both of them I cannot figure out how to protect generated xls file. I want to assure that generated file can be opened only by people that know password phrase. ...

Is the T class in generic Class<T> assignable from another class?

Edit Since there were many downvotes and people who didn't understand what I'm asking for, I'll rephrase: How do I find out at runtime what is the class that foo was generified from? public boolean doesClassImplementList(Class<?> genericClass) { // help me fill this in // this method should return true if genericClass implements Li...

What is variable shadowing used for in a Java class?

I'm reading my Deitel, Java How to Program book and came across the term shadowing. If shadowing is allowed, what situation or what purpose is there for it in a Java class? Example: public class Foo { int x = 5; public void useField() { System.out.println(this.x); } public void useLocal() { int x = 10; ...

Updating JPA entity with reflection does not work?

I have an entity which looks something like this: (I'm coding to the web page so I apologize for any mistakes) @Entity public class Entity { @Id private Long id; private String field; // Insert getters and setters here... } I try to manipulate it using reflection: Long id = 1; Entity entity = myDao.getEntity(id); e...

AssertContains on strings in jUnit

Is there a nicer way to write in jUnit String x = "foo bar"; Assert.assertTrue(x.contains("foo")); ...

what could modify the SerialVersionUID while serializing and storing in a Jarfile ?

Hello, I am facing some issues while serializing objects (I am using JBoss Drools, and want to store an ArrayList of KnowledgePackage). When I serialize the list, store the result in a file, and deserialize it, no problem occurs, so it works fine. But when I serialize the list, store the result in a byte stream, then save it in a JarF...

Does anyone know why Java AWT cursors get wrong hotspots on Vista?

When I'm create custom AWT cursors, it seems that they get the wrong hotspot when running on Windows Vista or Windows 7 -- the hotspot is offset by a few pixels to the right and down. On Windows XP and on Linux with X.org, I'm not seeing the problem at all. Is this a bug, or am I just doing something weird? I'm creating the cursors with...

How to rewind application state?

I'm developing a Java desktop flight simulation. I need to record all the pilot actions as they occur in the cockpit, such as throttle controls, steering, weapon deployment, etc. so that I can view these events at a later time (or stream them live). I'd like to add a visual replay feature on the playback of the events so I can visually ...

Java: Checking if a bit is 0 or 1 in a long

Given that : 0000000000000000000000000000000000000000000000000000000000000001 = 1 What method would you use to determine if the the bit that represents 2^x is a 1 or 0 ? ...

java replaceAll()

What is the regular expression for replaceAll() function to replace "N/A" with "0" ? input : "N/A" output : "0" thanx ...

Programmatically set a specific bean object - Spring DI

In my program I need to programmatically configure an ApplicationContext. Specifically, I have a reference to an instance of MyClass and I want to define it as a new bean called "xxyy". public void f(MyClass mc, ApplicationContext ac) { // define mc as the "xxyy" bean on ac ??? ... ... // Now retrieve that bean MyClass bean =...

Auto-generate stub methods that throw in eclipse

Similar to http://stackoverflow.com/questions/46003/how-to-change-generate-method-stub-to-throw-notimplementedexception-in-vs, but for Eclipse instead of Visual Studio Both NetBeans and Eclipse have a function that, if you declare a Java class to implement an interface but omit one or more methods, will automatically generate a stub met...

java.util.Logger behaves differently when packed in different OS

I run a java program from a jar file in Linux Redhat 4.3 and use eclipse for creating the jar file from my project. If I create the jar file when running eclipse in linux everything is ok (normal logfile name and normal text format in the logfile). However, if I create the jar when running eclispe under WinXP (and send it to my linux s...