java

Allowing garbage collection of a class while an anonymous inner class instance is referenced elsewhere?

I have a class A: public class A { private B b = new B() { public void method() { do something } }; public B getB() { return b; } } public interface B { void method(); } The instance b has an implicit reference of the instance of its outer class (that can be referenced by this). Now another object gets a reference to this b ...

Reflection a list of object which is serializable

I have asked a question in : reflect a list object I actually got my answer just want to understand why when do this I will hits illegalArgumentException : Can not set static final ArrayList SerialVersionUID to java.lang.long. But when I do one object reflect to another object no error. List<ClassB> listB = (List<ClassB>) convert(listA...

Can't read some attributes with SAX

Hi all, I'm trying to parse that document with SAX: <scxml version="1.0" initialstate="start" name="calc"> <datamodel> <data id="expr" expr="0" /> <data id="res" expr="0" /> </datamodel> <state id="start"> <transition event="OPER" target="opEntered" /> <transition event="DIGIT" target="operand" /> ...

Recursively list files in Java

How do I recursively list all files under a directory in Java? Does the framework provide any utility? I saw a lot of hacky implementations. But none from the framework or nio ...

Casting an Integer to a Double in XPath 1.0

I am currently building a XML based Jasper Report in which I am trying to add a tax percent onto the cost. A problem occurs when I use sum(//net-total) to value calculate the total cost. When the summed total has no decimal places it returns and Integer and I need a double. I have tried sum(//net-total) * 1.0 but it doesn't seem to wor...

Java Synchronized Block for .class

What does this java code means? Will it gain locks on all objects of 'MyClass' synchronized(MyClass.class) { //is all objects of MyClass are thread-safe now ?? } And how the above code different from this one: synchronized(this) { //is all objects of MyClass are thread-safe now ?? } ...

Format negative amount of USD with a minus sign, not brackets (Java)

How do I get NumberFormat.getCurrencyInstance() to print negative USD currency values with a minus sign? ...

Accessing JBoss Cache deployed on a remote JBoss AS (4.2.2)

Hi all, I have deployed the JBoss cahce service to my JBoss AS which is running remotely in a completely separate VM. I am now struggling to access the cache deployed to the AS. Does anybody have any suggestions? Thanks In Advance ...

Java-Spring-Hibernate: How can I save a filter and, afterward, how could I use it?

I receive a task for a project which uses Spring, Hibernate and Wicket. In a particular HTML page I must have the possibility to create a filter(set the name of the filter and its parameters). I must create a list of filters in this way. In the same time, I must have the possibility to edit and delete the filter, and of course, to use t...

How to instantiate generic variable like Class<Foo<T>>?

I need to instantiate generic variable like Class>. For example, Class<? extends List<String>> = ... Variant 1: Class<? extends List<String>> clazz = LinkedList.class; don't work - "Incompatible types". Variant 2: Class<? extends List> clazz = LinkedList.class; work, but in this case List is a raw type - not good. How to insta...

java generics and SuppressWarnings

I have classes abstract class A { //.... } class B extends A { //.... } class C extends A { //.... } Then I have interface Maker<T extends A> { SomeClass make(T obj); } implementations for Maker class class MakerForB implements Maker<B> { /*... */ } class MakerForC implements Maker<C> { /*... */ } and class F...

Hessian Web service invocation from a JavaFX Applet

Hi, I'm trying to invoke a Hessian Web Service from a JavaFX applet. I know it needs some reflection permissions so I signed it myself for testing but even then it doesn't work. The browser asks me if I accept the certificate, I click yes but I receive the permission exceptions anyway: com.caucho.hessian.client.HessianRuntimeException:...

Does JAX-RS require data transfer objects (DTO)?

If a method of a JAX-RS application would return a domain object, the representation (say JSON) would contain all attributes of this object - right? But what if this object would contain "private" data, that shouldn't be exposed to the web? And what is about the other direction from outside in: how could be prevented that private fields...

Swing problem!(problem in showing a frame)

Hi, sorry for posting a lot of code!!I don't know that why my ListFrame doesn't work??? these are the classes.At first I run the MainServer and then I will run the MainFrame in the other package.and then by inserting a correct user name and password ,the Listframe will be shown,BUT I click on menu bar or list or delete button but nothing...

Deployment solution automatic compile

At the moment I use SVN to manage java source code. Is there a solution out there whereby I can check in code and have the new code automatically compiled into a JAR file? Somehow the check in would need to trigger the compile process. ...

How to webscrape scholar.google.com in Java?

I want to write a Java func grabTopResults(String f) such that grabTopResults("automata theory") returns me a list of the top 100 cited papers on scholar.google.com for "automata theory". Does anyone have suggestions for what libraries will make my life easy? Thanks! ...

Is there an easy way to generate an Ant build script from a Maven POM?

Hi there, We have a project that uses Maven as its build/dependency management tool. But our code needs to be compiled at our client's site and our client demands that we deliver build scripts written for Ant. So, we would like to keep working with Maven and automatically generate the Ant scripts when we need to deliver the code to the...

What is the Java Equivalent of Python's property()?

I'm new to Java, and I'd like to create some class variables that are dynamically calculated when accessed, as you can do in Python by using the property() method. However, I'm not really sure how to describe this, so Googling shows me lots about the Java "Property" class, but this doesn't appear to be the same thing. What is the Java eq...

can sessions be periodically recycled depending on server load?

With servlets/jsp, can sessions be recycled by the web container (say tomcat), depending on how much traffic a site is getting? Update By recycled I mean, the tomcat container will wipe it out since it is running out of memory or busy trying to server requests for another website on the same server This happens with IIS and .net ...

cannot write to pty - linux

i am the owner of the pty device created like this permissions are crw-w---- mknod pty1 c 1 1 cat > pty1 tells me operation not permitted. what i want to do later is that i open the file from a program using open and call write to send output to the terminal, as if it is a disk file. why is cat not working. can we write to a pty or ...