java

Java memory model - can someone explain it?

For years and years, I've tried to understand the part of Java specification that deals with memory model and concurrency. I have to admit that I've failed miserably. Yes' I understand about locks and "synchronized" and wait() and notify(). And I can use them just fine, thank you. I even have a vague idea about what "volatile" does. But ...

Should an interface that is inherited from base-class be implemented explicitly in subclass?

My question is, if an interface that is implemented implicitly by extending a class that already implements it, should be explicitly implemented by the class, if the class wants to advertise the fact, that it fulfills the contract of that interface. For instance, if you want to write a class, that fulfills the contract of the interface...

Creating a child applet window from a parent applet

How do I create an applet window outside the web browser from within an applet running in that browser? ...

In Java, what happens if you use Double.NaN in an operation?

I have compiled code that erroneously tries to add a number and Double.NaN. I'm wondering if it's throwing an exception that's not getting caught? Does anyone know how that situation is handled? Thanks. ...

image uploading in grails

hi, I am new to grails.I am doing web application that uploads the image from client side and it stores that in server. My Gsp code is: <g:uploadForm action="saveImage"> <input type="file" name="image"> <input type="submit" value="Submit"> </g:uploadForm> My saveImage action in controller is: def saveImage={ def file = request.get...

Why I get an Exception on opening an empty ZIP-file with java.util.zip.ZipFile?

I want to open a ZIP-file, that have no entries with java.util.zip.ZipFile. But on the constructor I get the following exception: 'java.util.zip.ZipException: error in opening zip file'. How can I open the empty ZIP? That ZIP-file is created by the commandline zip-program under linux. I simply deleted all entries from a ZIP-file. I nee...

Does the code-to-interface principle apply to entity classes?

I'm trying to follow code-to-interface on a project. Should I be creating an interface first then implementing that interface for entity classes? I'm thinking this might be taking the interface first approach too far and entities should be ignored. This is what I mean... public interface Address { public String getStreet(); publi...

Nesting SAX ContentHandlers

I would like to parse a document using SAX, and create a subdocument from some of the elements, while processing others purely with SAX. So, given this document: <DOC> <small> <element /> </small> <entries> <!-- thousands here --> </entries> </DOC> I would like to parse the DOC and DOC/entries elements...

MCImageManager external authentification

Hello, Could you explain me how to use the external authentification of MCImageManager with a jsp or a servlet ? What should be the result of this jsp or servlet ? What would be the parameters ? Thank you in advance. ...

What is the meaning of Self-signed checkbox in WebStart properties in Netbeans

In Netbeans (I have the 6.5 version), in the project properties under Application> Webstart there is a self-signed checkbox. What is its meaning? When I need to use it? ...

Java or ABAP Web Dynpro? (SAP Web Development on Netweaver)

Are there any good arguments for using Java Web Dynpro over ABAP Web Dynpro? I've heard that the Java version is more mature by about 18 months because Dynpro was made for Java, and then ABAP devs wanted it once they saw it working. I know ABAP is propriatary to SAP and the Java is much more widely used. Does this fact, plus the maturit...

Getting the value from an EnumSet in Java

If you use an EnumSet to store conventional binary values (1,2,4 etc), then when there are less than 64 items, I am led to believe that this is stored as a bit vector and is represented efficiently as a long. Is there a simple way to get the value of this long. I want a quick and simple way to store the contents of the set in either a fi...

Java: generating random number in a range

Hello, I am trying to generate a random number with Java, but random in a specific range. For example, my range is 5-10, meaning that 5 is the smallest possible value the random number can take, and 10 is the biggest. Any other number in between these numbers is possible to be a value, too. In Java, there is a function random() in the...

Two IDEs have different results.

My co-worker and I are working on the same project, but we use different IDEs. He uses Eclipse 3.4 and I use IntelliJ 8.0. Recently I advocated using EasyMock, which uses CGLIB, for some unit tests on our project. I have not seen any problem setting breakpoints in IntelliJ on the partial mock objects generated by EasyMock, but my co-wor...

Setting the tab policy in Swing's JTextPane

I want my JTextPane to insert spaces whenever I press Tab. Currently it inserts the tab character (ASCII 9). Is there anyway to customize the tab policy of JTextPane (other than catching "tab-key" events and inserting the spaces myself seems an)? ...

Program with C# front-end and Java back-end: Good or Bad Practice?

Hello, My friend and I are having a disagreement over an application development issue. It's a simple production management application. According to my friend, the front-end stores data in XML, and a Java program will read the XML document, store it (at the back-end), and apply some business logic and again store the results into ano...

What is the best way to convert an existing php class into Java?

I have been tasked with converting several php classes into java classes, which is quickly becoming a nightmare for me. I understand the basic language structure, it being similar to C. It is all of the function calls and class calls that seem to go nowhere and the fact that a var can be declared in the !middle of an expression! that is ...

Approach to convert from org.joda.time.DateTime to java.util.Calendar

Anyone done this and can share? I see an option or two but want to know what others have accomplished. ...

Can I add jars to maven 2 build classpath without installing them?

Maven2 is driving me crazy during the experimentation/quick and dirty mock-up phase of development. I have a pom.xml file that defines the dependencies for the web-app framework I want to use, and I can quickly generate starter projects from that file. However, sometimes I want to link to a 3rd party library that doesn't already have...

Using java.io.Serializable when implementing a tree?

Hey everyone, I have ANOTHER serialization question, but this time it is in regards to Java's native serialization import when serializing to binary. I have to serialize a random tree that is generated in another java file. I know how serialization and deserialization works, but the example I followed when using binary serialization wi...