java

Concurrent Modification exception

I have this little piece of code and it gives me the concurrent modification exception. I cannot understand why I keep getting it, even though I do not see any concurrent modifications being carried out. import java.util.*; //package p2; public class Class1 { public Class1() { } public static void main(String[] args) { ...

How to log the time taken by methods in Springframework?

Is it possible in springframework to log the time taken by methods [ selective | all ] automatically. By automatically i mean, i don't want to go to each method and write the log.debug ( "...." ); stuff. ...

How to create shortcut icon for java program

Hi I have created executable jar of my java program i want to create shortcut icon for that jar. Means may be my jar is in any other memory location of hard drive(eg- D or E drive for windows) but my icon must be at Desktop. So that if i double click on icon from desktop then my application will start. How to create this Thanks Sunil Ku...

Converting binary to decimal JAVA

whats a way to convert a binary string to a decimal integer without using Integer.parseInt ?? ...

How can i use JUnit in Servlet and JSP?

I am writing a web application which should be tested with JUnit framework. So please suggest me how we can use JUnit in Jsp and servlet and also how to generate test case reports using Ant?? Thanks in advance Why cant we use Cactus? I have heard about that and what it differs from other test cases? ...

Syntax Question IF ELSE (Java)

what is the java syntax for saying if x is not equal to a or b I am trying to write an if else statement .. if a certain value is not equal to say 2 or 3 then do something else do something else :) thats confusing lol ...

Two BlockingQueue - deadlock

I have a requirement to manipulate two queues atomically and am not sure what is the correct synchronization strategy: This is what I was trying: public class transfer { BlockingQueue firstQ; BlockingQueue secondQ; public moveToSecond() { synchronized (this){ Object a = firstQ.take(); secondQ.put(a) } } public moveToFirst() { synchron...

Virtual Dedicated Server Question

Hi I have a Virtual Dedicated Server, how can I run an application periodically (ie: every Monday - 19:00). I mean, the application starts automatically at a given time. Is there any way to do it with Java, Ajax, PHP? (sorry, I'm noob) ...

RMI client in a OSGi container

I need to expose a RMI-based system in an OSGi bundle. The RMI client "bundle" is a jar which I converted into a OSGi bundle using the bnd tool (I don't have access to the sources) and at least in eclipse everything seems to be fine, but when I try to connect to the RMI server, a ClassCastException is throwed, much probably because eithe...

how to get oracle port no from sql query

Hi, Is it possible to get the oracle server port no from a sql query? Thanks, Fell ...

How do I determine the position of the nth most significand bit set in a 64-bit value?

I'm using some long values as bitmaps in a Java program. Here's my method so far: public class BitmapUtil { private static final long _B_MASK_LEFT_ON = 0x8000000000000000L; public static long setNthMsb(int n) { return BitmapUtil._B_MASK_LEFT_ON >>> n; } public static boolean isNthMsbSet(long b, int n) {...

How to make a singleton class threadsafe?

I am implementing a singleton class in Java to make sure no more than one instance of the class is created. ...

Conversion of Delphi code to Java

Does a parser exist for delphi which can be used to convert the delphi code into Java code automatically? Please Help!!! ...

Do static members help memory efficiency?

If I have a class that I expect to be used in thousands of instances in a memory-sensitive application, does it help if I factor out static functionality to static members? I imagine that static methods and variables are stored once per class while for non-static members there has to be something stored for each instance. With member v...

Anchoring and Docking Controls in java Swing

In .net there is a control called anchoring that is used to resize controls dynamically with the form. When a control is anchored to a form and the form is resized, the control maintains the distance between the control and the anchor positions. My question is that is there any controls in java that does same functionality as anchorin...

How can a singleton class use an interface?

I read at many places that singletons can use interfaces. Some how I am unable to comprehend this. ...

Java generics design problem

i want to dispatch messages to specific handlers through a common message processor // // Library code // abstract class Processor<M extends MessageHandler<? extends Message>> { HashMap<Class<Message>, M> handlerMap; void addHandler(M, Class<Message>); void run() { while(true) { ... } } /...

How can I reuse an instance of a webservice?

I am running a service A which has a class X. I am going to deploy another service B on same machine which is using this class X. How can I make sure that the same instance of service A is reused instead of another. PS:Service written in JAVA. Adding: Both these services are Axis2 services. Service B is hot-deployed. Service B used cla...

Not yet ported Java libraries for .NET

Hi, I often read and feel that .NET Framework has much less libraries to use in project than available in Java world. Even if some ports exists, a lot of them are not at the full speed/active. One example is Apache NFOP. It has not been updated for a while. Another is NHibernate - it is very active but does miss a lot of features that ...

Findbugs + JSR305: Possibility to specify default behavior?

Hello! Note: those annotations, I'm talking about, are specified by JSR305. I have the latest Findbugs (1.3.9) and it finds errors correctly when some field, annotated with @Nonnull, is assigned to null. But, in my project, the "non-null logic" is the default case. I would say that null is explicitely allowed only in 5% of cases. So,...