java

Why are there finalizers in java and c#?

I'm not quite understanding why there are finalizers in languages such as java and c#. AFAIK, they: are not guaranteed to run (in java) if they do run, they may run an arbitrary amount of time after the object in question becomes a candidate for finalization and (at least in java), they incur an amazingly huge performance hit to even s...

what is faster flex and Java or flex and php?

Hello stackoverflowers, we are designing a major webapplication for the www. It a social community site. and i would like to know witch direction i need to take. What works faster, flex and php or java and flex? i've read that flex and php with amfphp is very fast (with AMFEXT). but i have seen that 90% of the major companies here i...

What is the time complexity of java.util.HashMap class' keySet() method?

I am trying to implement a plane sweep algorithm and for this I need to know the complexity of java.util.HashMap class' keyset() method. What i feel, it would be O(n log n). Am I correct? **Edit I am talking about the time complexity of the method keySet(), the walking over will take surely O(n) time. But I am not sure, how it retrieves...

Java Swing JList

Hello. I'm trying to make a JList to display the contents of an array. The array itself is not an array of strings, however, but an array of Objects. Is it possible then, to use the same array of objects as the parameter to construct my JList (if the Objects are given a toString method)? Thanks. ...

JTree data from database

Hi all, I'm working on the example at http://java.sun.com/docs/books/tutorial/uiswing/examples/components/GenealogyExampleProject/src/components/GenealogyExample.java I wanted to customize it in a way the data are pulled from a table instead (folder_id, folder_name, parent_id[foreign key to determine parent] . Here is my code publi...

Call a function based on JVM version.

I have a JFrame object, and i need to support two JVM 1.5 on Mac OS X and 1.6 on Windows. On windows I need to use setIconImages function to set multiple icon sized for the application but this function is not availible on 1.5. Is it possible to call this function inside JFrame with reflection? Application extends JFrame{ . . . void i...

resize required to view images in java applet

Hello all, I'm working with java images for the first time and having a problem viewing them when the applet loads. If I resize the window they display fine. I feel like this is a common first-timer error. Has anyone else encountered this? Any idea what the fix could be? What I believe to be the pertinent parts of the code are listed...

Java Swing Updating JList

Hello again. I'd like to know if there is any way that I can update a Jlist after the user adds or removes an item to it and after a user sorts it. Is there any way that I can write a standardized method to update the display based on the order of items in an array or vector, and when the user remove or adds an object from the array tha...

Updating position of JSlider Swing

My apologies for posting tons of questions as of late. I'm trying to get a JSlider to update its position based on a constantly updating variable. The setValue(n) method doesn't seem to work. Is there any alternative? We're using this as a time marker for a music player. ...

java synchronized block for more than 1 objects?

Hi, I have two arrays, and I need to synchronize access to them across threads. I am going to put them in a synchronized block. The problem is, I can pass only one of them to 'synchronized' st one go. How do I ensure that the access to both the arrays is synchronized? Do I put them in a class and create an object of it? Or I access th...

export a report in ms word(97-2003) without using RTFExporter in jasper reports

I have a report which needs to be exported in pure word format(97-2003) using jasper report. But Jasper uses RTFExporter for exporting report in doc format, wen i read the report using POI, it throws error saying its not pure word. Can anyone help how to generate a report in word using Jasper reports. Please help! ...

Is there any java code for Othello

i would to like need the baisc Othello as this : 0 : 0 0 0 0 0 0 1 : 0 0 0 0 0 0 2 : 0 0 1 2 0 0 3 : 0 0 2 1 0 0 4 : 0 0 0 0 0 0 5 : 0 0 0 0 0 0 ...

Godaddy Java support and Confusing and Many problems

Dear All, Could any body please help me ? I called godaddy several time and still no proper answer. Problem 1) Hosting Plan :- I asked for Java linux unlimited host plan and initially they gave me Linux Web Hosting - Unlimited - 3 years but My simple Hellowrold JSP not worked(showing the full file contents with JSP tags) so I called ...

Steps to "Mavenize" a Eclipse or NetBeans project with the help of Subversion?

The process of mavenizing Eclipse and NetBeans projects usually takes a lot of manual work, if all files are under revision control. So I am thinking of writing an Ant script which uses svn commands to rearrange the files in the working copy according the standard Maven directory layout. This would keep all file revision histories inta...

api comment of ListIterator

In the API: public ListIterator<E> listIterator(int index) Returns a list iterator of the elements in this list (in proper sequence) What is the meaning of proper sequence? List<Integer> list=new ArrayList<Integer>(); list.add(1);list.add(2);list.add(3); /**IS the sequence returned by i1 and i2 is the same?*/ ListIterator<Integ...

Decoupling backing store with Spring Web MVC

This is a design pattern question, so I'll illustrate it with a simple example of an address book app. Firstly a few assumptions. 1. It appears to be acceptable to directly use DB domain objects as the backing store for Spring MVC forms. Iteration 1 of my app I created a JPA mapped Person object with various attributes attached. Using ...

Reading in and Writing out in Java Program Question

Hello, this isn't a general question about read or write. I have written a program in Java to read in a text file of some metadata from images. They contain names and a long list of them sometimes over 4000 names. Unfortunately, many of these names are the same and so I wrote a program that takes the list in a .txt file and gets rid of t...

Java/JVM for C++ programmer?

What books can you recommend for learning Java for a C++ programmer? Also what do you recommend to read for learning JVM features for using JVM-based languages effectively? ...

How do I get the Java compiler to tell me what type it infers?

When I have a Java generic function like: <T> T choose(T a, T b) { } and I call it from somewhere, how can I find out what type is inferred for T? Edit: Type inference happens at compile time. So what I'm asking is, how do I get the compiler to tell me some information (the inferred type) it has during compilation, but that doesn't ...

Nested synchronized blocks on interned Strings

The title sounds like there is a lot of problems ahead. Here's my specific case: This is a travel tickets sales system. Each route has a limited quantity of tickets, and so purchasing the last ticket for a given route shouldn't be accessible to two people (a standard scenario). However, there is the "return ticket" option.. So, I'm usin...