java

Good design for persisting a JPA domain object

I have a domain object that stores some metadata and some raw bytes. This is used for storing binary objects such as PDF documents and images. I would like to persist the metadata in a database so it can be easily queried but I want to store the raw bytes in the file system for performance reasons. What is a good design for achieving th...

Can I mix declarative and programmatic layout in GWT 2.0?

I'm trying to redo an existing panel that I made before GWT 2.0 was released. The panel has a few text fields and a scrollable panel below in a VerticalPanel. What I'd like to do is to make the scrollable panel with UIBinder and then add that to a VerticalPanel Below is an example I created to illustrate this: public class ScrollTabl...

How to convert .txt to .mht?

How to convert a flat .txt file to .mht? What APIs are available to help with the conversion? ...

Groovy Superset of Java

Is Groovy a superset of Java yet? If not, what are the incompatibilities between Groovy and Java? By superset, I mean source backward compatibility, in the sense that: you can take a Java file and compile it as Groovy source file, and it would work just as before. It has been the goal of Groovy to make very similar to Java, to minimiz...

help me in Stateful beans

Question 1: As per the book I follow to learn EJB author told that every lookup creates a new stateful session bean. So, what I did is defined a method init() with @PostConstruct annotation with a sysout statement. So, that need to be executed for every Stateful bean instantiated. But the same is not happening. Consider the following cod...

best java book for web development

What would the best java book be, that covers web development in detail? Also, if there is a book that emphasizes design patterns etc. in web development, best practices, etc, that would be great. ...

Why http://localhost:8080 availabe while 127.0.0.1 not? (JSP on MyEclipse+Tomcat)

The System's hosts file is fine, 127.0.0.1 localhost is there... Ping 127.0.0.1,or my IP, the result is also fine.. Myeclipse's version is 8.0 and I'm just using the Tomcat within it. A simple JSP+Javabean web project so is deployed. Now the situation is when I open MyEclipse and start the Tomcat, I can access my site throuth http://...

How to programmatically add Security to a Spring Bean

I´m using spring-security-tiger-2.0.5. Is there a way to programmatically add a security proxy to a Spring Bean? I´m constructing the bean through BeanDefinitionBuilder, and i´d like to add same behaviour as the @Secured annotation. The roleName´s @Secured equivalent will be passed as a parameter. ...

Inheritance of Interface implementation in Java

I have two questions regarding interfaces in Java. 1) If a class happens to implement all the interface methods of interface I, without declaring itself as implementing them, can it still be used as input into variables of type I? 2) Does a subclass of class A which implements interface I inherits the conformance to that interface, or s...

which non-sun java(s) can i use to run Clojure?

I'm automating the process of building development-VMs for a project and having a really hard time getting sun-java-6 to install in a non-interactive environment because it really wants to ask about licenses. what are my other options are far as clojure friendly javas go? ...

How to let the servlet container (Tomcat) interrupts/destroys a servlet request?

Dear All,,, I am new in Servlet, I used the following code to read some inputStream, class MyServlet implements Servlet{ void service(ServletRequest req, ServletResponse res){ InputStream inA, inB, inC; //... inA.read(); // May block inB.read(); // May block inC.read(); // May block // ... } } How to let the se...

No digits Java Regex Pattern

hi I want a regex pattern to check that the string doesn't contain any digits . For Illustration : I'm coding a Hospital System and I want from user to enter the name of the patient , Of course the name shouldn't contain any digits , how can I do this by Regex ? ...

How to find object of given type in a heterogeneous List

I have a heterogeneous List that can contain any arbitrary type of object. I have a need to find an element of the List that is of a certain type. Looking through the answers of other generics related questions, I'm not finding exactly what I need. Here's an example of what I'm trying to accomplish: List <Object> list = new ArrayList ...

Regarding java.math.BigInteger

The problem im facing with BigInteger when i try computing a string like "7+3" and then storing the result in a BigInteger variable, it throws a NumberFormat exception. Any pointers on how this can worked on? Eg: String ist="7+2"; java.math.BigInteger a = new java.math.BigInteger(ist); ...

hashCode of Double.POSITIVE_INFINITY

I've recently encountered an odd situation when computing the hash Code of tuples of doubles in java. Suppose that you have the two tuples (1.0,1.0) and (Double.POSITIVE_INFINITY,Double.POSITIVE_INFINITY). Using the idiom stated in Joshua Bloch's Effective Java(Item 7), these two tuples would not be considered equal (Imagine that these t...

how does the hashCode() method of java works ?

Hello I am curious how java generates hash values by using hashCode() method of the Object API ? ...

When to use ServiceLoader over something like OSGi

Being someone who is allergic to dependencies, when would I use something like OSGi instead of the built in java 6 http://java.sun.com/javase/6/docs/api/java/util/ServiceLoader.html (I want to let plugin jars just be dropped in). (FYI this is in a scala app, open to any suggestions, ServiceLoader is pretty damn close to what I want). ...

Groovy, Scala maybe making my life easier?

I don't want to break any rules here but happy christmas everyone of you! In a silent hour an idea crossed my mind: Is it possible to replace any java coding which I use daily with groovy or scala? E.g. writing small webapps which include servlets/portlets etc. ...

Java polymorphism question

For SCJP most of the time question such as below is asked to find valid example of polymorphic method calls. But what should one exactly look for to find is it polymorphic use or not ? abstract class A { abstract void a1(); void a2() { } } class B extends A { void a1() { } void a2() { } } class C extends B { void ...

The support for the development of java swing in Netbeans 6.7 and 6.8 isn't good ?

when design when run when design and run in netbeans 6.5 they are the same, but int 6.7 and 6.8, as you see, they are different! ...