java

how to focus a JFrame?

I am writing a small game, with one JFrame that holds the main game, and another JFrame that displays the score. the problem is, when I am done constructing them, the score JFrame always ends up focused! I have tried calling scoreDisplay.toFront(), scoreDisplay.requestFocus(), and even: display.setState(JFrame.ICONIZED); display.setStat...

Glassfish hangs on OS X 10.5/Java 6

I want to play around with glassfish on a Mac, but I'm having trouble getting it to start. I've followed the installation instructions and created a default domain, which seemed to go fine, but when I try to start it (asadmin start-domain domain1) it just sits there: [kris@Macintosh-2:~/glassfish] ./bin/asadmin start-domain domain1 Sta...

How to get value from struts bean?

I am new to struts. I'm just trying to build a simple application that gets the input from the user and display it. For which I got the input from the user and stored it in a bean and I have also displayed it in the next page using bean:write but how to place it in a text box. I tried to use html:text but I don't know how to place the v...

Error while connecting to DB2 from JBoss Application Server

Hi, I'm trying to connect to the AS400 database DB2 from a Java application hosted in JBoss application server. But, I'm getting the below error when ever I run my application: Apparently wrong driver class specified for URL: class: com.ibm.as400.access.AS400JDBCDriver, url: jdbc:as400://DBSYTEM;driver=toolbox;trace=false;errors=full;p...

Can I specify a hibernate relationship with a filter?

I have a foo that has a relationship to many bar's. When I delete bar's in my system I want to keep them in the database for some crazy business reason so I just set a deleted field to true. Can I specify in my hibernate mapping that I only want my collection to hold elements where that field is false? ...

Can using too many static variables cause a memory leak in Java?

If my application has too many static variables or methods, then as per definition they will be stored in heap. Please correct me if I am wrong 1) Will these variables be on heap until application is closed? 2) Will they be available for GC at any time? If not can I say it is a memory leak? ...

How did you prepare for the Sun Certified Java Developer (SCJD) certification?

Title pretty much says it all. For obvious reasons, I'm only interested in your answer if you passed. EDIT: While I appreciate the comments about the SCJP exam, I am asking about the SCJD, which is administered in a very different fashion from the SCJP. EDIT 2: Comments on the value of certifications are also not useful. My question as...

Are threading issues for C/C++ "system level programmers" significantly different from those faced by Java programmers?

I'm looking for a development job and see that many listings specify that the developers must be versed in multithreading. This appears both for Java job listings, and for C++ listings that involve "system programming" on UNIX. In the past few years I have been working with Java and using its various synchronization mechanisms. In the...

Why would one declare a Java interface method as abstract?

I used the "pull interface" refactoring feature of Eclipse today to create an interface based on an existing class. The dialog box offered to create all the new methods of the new interface as "abstract" methods. What would be the benefit of that? I thought that the fact that you were allowed to declare interface methods as abstract wa...

How to Host mail using java api ????

Hi, i want to host mail on my machine.So i can able to send and received mails through my machines. is there any api in java to do the same.. thanx ...

Rounding a Java BigDecimal to the nearest interval

I have a BigDecimal calculation result which I need to round to the nearest specified interval (in this case it's the financial market tick size). e.g. Price [Tick Size] -> Rounded Price 100.1 [0.25] -> 100 100.2 [0.25] -> 100.25 100.1 [0.125] -> 100.125 100.2 [0.125] -> 100.25 Thanks. Update: schnaader's solution, translated into J...

Capturing kill signal in Eclipse RCP application

I've got a command line version of an Eclipse RCP GUI application that can makes use of a lot of the same plugins (this is handy for integration testing). One thing it does is connects to a server, requests stuff and starts an interactive loop. To exit, the user of the GUI app can stop the loop and close the application. In my command l...

CXF generated web service client

When using a generated webservice-client (CXF and Maven-Plug-in) I got the following error: Interceptor has thrown exception, unwinding now null. Can someone help me? Thanks! ...

How can I make sure N threads run at roughly the same speed?

I'm toying with the idea of writing a physics simulation software in which each physical element would be simulated in its own thread. There would be several advantages to this approach. It would be conceptually very close to how the real world works. It would be much easier to scale the system to multiple machines. However, for this t...

Deploy java (command line) app using Netbeans / ant

I've finally managed to create a Netbeans project out of an old standalone (not Web-) Java application which consisted only out of single .java sources. Now I have basically two questions regarding Netbeans Subversion interaction and application deployment: Do you check in all the Netbeans project files into the repository, normally? I...

Best Practice: How to check for a specific java.util.Calendar/Date in SQL.DATE by JDBC?

This is something I struggle with since yesterday. I have appointments to save in a database. They consist of a date and a time, like: 01.02.1970 14:00 (german format, in american I think it would be something like 02/01/1970 2:00pm). First idea: Save it as a SQL.DATE! So i created a table: CREATE TABLE appointments (id NUMBER(10...

How do i create a movie from a set of images using qtj and java?

I have a set of images i want to add one after another and create a movie. I will be using Quicktime for java for this(I'm on a mac). I searched the web i have found lots of examples that show how to play movies using qtj, but i can't find any code snippets or tutorials showing how i can create a movie frame by frame using qtj? ...

How can I retrieve a JDBC ResultSet as an ArrayList?

I'm doing a query to retrieve a large amount of IDs (integers). Instead of iterating millions of times through the ResultSet and copying everything one-by-one to an ArrayList, is there some way to simply retrieve everything as an ArrayList? I understand that ResultSet is supposed to be iterated because the underlying implementation may ...

Receiving a Java Method without using getDeclaredMethod

Hi, I wish to initialize an array of java methods in the child class, as a class field like so void callme() {System.out.println("hi!");} Method[] actions = new Method[] {&callme,&callme}; and call all methods in this array at parent class like so: for (meth:actions) {meth.invoke();} However currently I cannot find a way to implici...

Best way for Java to write/read file on a separate machine?

We have a Java application server running on Sun Solaris. We now need to be able to write files and read files to/from a separate machine, which is running WindowsXP. These 2 machines are administered by 2 separate groups within the same firewall. If it is easier, we could use Java to write the file to Solaris and then use some 3rd pa...