java

Error using JMF

I set up JMF using this tutorial http://www.deitel.com/articles/java_tutorials/20060422/PlayingVideowithJMF/ . I set up the mp3 codec in the jmfregistry like you are suppose to and I am able to play any mp3 I want when I use jmstudio. This means I set up everything correctly but when I execute my code I still get this error message: Una...

How to use Spring to inject an object in a setter that doesnt follow the Java bean specification ?

I am trying to use Spring and wx-xmlrpc together. The problem is that XmlRpcClient has a setConfig() method that doesnt follow the Java Bean spec : the setter and the getter dont use the same Class. So Spring complaints when I have the following context.xml : <bean id="xmlRpcClient" class="org.apache.xmlrpc.client.XmlRpcClient"> <pr...

Custom taglib - .tag files recompiled on every request. Is this normal?

I'm creating a custom taglib with .tag files. Everything works great, except when I load 2 pages at the same time. It seems the .tag files are re-compiled on every request and the concurrency causes the compilation to fail. Is this normal behavior for .tag files? I would have expected them to be compiled only once. Is there some way t...

Java AffineTransformOp memory question

I'm trying to apply an AffineTransform to an image in Java. Here's the code that I'm running. AffineTransformOp op = new AffineTransformOp(atx, interactive ? interpolationInteractive : interpolationNormal); displayImage = op.filter(displayImage, null); Where atx is a valid AffineTransform object. This code seems to run fine, ...

refactoring multiple if-else conditionals in a method

I am in the process of refactoring my existing code. It actually works fine, but it is a bit cluttered with multiple if-else conditionals checking the value of one variable and change the value of a second variable to an updated value taken from a fixed enumeration structure. else if (var1 == 'valueX') { if (var2 == MyEnum.A) var2 = ...

What would happen if I set null in prepared statement with varchar always?

I have this method to insert data using jdbc that will insert the value according to the java type. Something like this: Object o = map.get( key ); if( o == null ) { // setNull( index ); } else if( o instanceof String ) { // setString( index, (String) o ); } else if( o instanceof Timestamp ) { // setTimestampt( index, ( Ti...

Java: Complete code examples of thread-per-connection blocking IO versus NIO?

Ok, I'm going crazy here. I have been rewriting the NIO code for my server, and running into some real headaches. The bottom line is that getting NIO "right" is very hard. Some people pointed me to the Rox tutorial at http://rox-xmlrpc.sourceforge.net/niotut/, which seems to be on a good path, but is not as complete as I would like. ...

Get the return value of JOptionPane

My JOptionPane code is as follows: selectedSiteName = JOptionPane.showInputDialog("Enter the name of the new site:"); This renders out an input with a textbox and an OK and Cancel button. I need to detect if Cancel was clicked. Cheers. ...

Java interface and inheritance

If we have: public interface Foo{} public class Bar implements Foo{...} Is there a difference between: public class BarBar extends Bar implements Foo{..} and public class BarBar extends Bar{..} I see a lot of code like this and it always confuses me. Does BarBar need to implement Foo? I mean since it extends Bar to begin with i...

Select nvl(max(c.EmployeeId),0) in JPQL?

I'm using oracle10g database and eclipselink, I need to obtain the last inserted key from the table so i've created this query javax.persistence.Query q = em.createQuery("SELECT nvl(MAX(c.myAtt),0) " + "from myTable as c"); return Integer.parseInt(q.getSingleResult().toS...

How can I know if 10385274000 fits into: NUMBER(10) for Oracle

I been working the whole week to troubleshot a production error. I have eventually got the the point where I can find the culprit record which is causing all the mess. I've got the following error message: java.sql.SQLException: [BEA][Oracle JDBC Driver][Oracle]ORA-01438: value larger than specified precision allows for this column ...

Is it legal to call the start method twice on the same Thread?

The following code leads to "java.lang.IllegalThreadStateException: Thread already started." the second time it is run through on the program. updateUI.join(); if (!updateUI.isAlive()) updateUI.start(); This happens the second time updateUI.start() is called. I've stepped through it multiple times and the thread is called ...

How can I solve this PicasawebService error?

I am just trying to get some things to work so I can try some of google app engines java. However I seem to have a problem with something that I can't get a hold of. The java code looks like this: import java.net.URL; import com.google.gdata.client.photos.*; import com.google.gdata.data.photos.*; public class TestPicasa { public stat...

another java.lang.ClassNotFoundException in ant's junit task

I can't figure out why I am getting this exception from my ant build.xml file. I checked and everything is in the classpath. Why must this be so complicated?! I had trouble with Ant in the past and it seems it always is something related to the classpath. I am pointing to junit.jar using both ways: within eclipse: window->preferences->a...

increase the width of a column dynamically in jasper reports in java

How do i increase the width of a column in jasper reports dynamically in java, i have tried changing many things in java side like reading the style sheet and changing the values. But in this case i don't know how to initialize the method which will read the width and change it. ...

creating an executable jar file with ant which includes the build.xml file

Hello, I am trying to use ant to build an application, run the application's main() method, run junit tests, and package everything in a jar file (source+build+libraries+build.xml). The classes include a runner class with a main() method entry point. The objective however is to inlcude all libraries used, like junit.jar, and the ant bu...

Creating an object of activity class

Hi, I am having an class which extends Activity and i am trying to create an object of that class in normal java class ,It is giving me an exception "Cant create handler inside thread that has not called looper.prepare" ,what i am doing wrong Thnx in advance. ...

The difference between Classes, Objects, and Instances

What are class, object and instance in the context of java? Please illustrate your answer with examples. ...

JDBC and Threading

Hi all I have a program that needs to query a database in a given interval and with the records it gets call perform some action, then update the table again. I am using the ExecutorService to run the threads, but am wondering, should each thread get its own connection (because it needs to update database) or can I use the same connect...

How to render text into a box and replace excess with three dots

I render text with a custom table cell renderer and I want to trim the text drawn if it would exceed the current cell width, switching to a "This text is to long..." kind of representation, where the three dots at the end never leaves the bounding box. My current algorithm is the following: FontMetrics fm0 = g2.getFontMetrics(); int h ...