java

Image display within GridBagLayout Java

My image is passed into my program from a server and saved as a string. I want to convert that string into an image, and then in turn display that image within a label inside of a GridBagLayout. When I execute the below code, I get a blank frame. No exceptions during execution. When I look at the image object from the ToolKit in debug, i...

BufferedReader for large ByteBuffer?

Is there a way to read a ByteBuffer with a BufferedReader without having to turn it into a String first? I want to read through a fairly large ByteBuffer as lines of text and for performance reasons I want to avoid writing it to the disk. Calling toString on the ByteBuffer doesn't work because the resulting String is too large (it throws...

Handling many simultaneous AJAX requests with a struts2 action

I've got a struts2 action that responds to an AJAX request by taking some request parameters, calling a remote service that returns XML data, then transforming the data via XSL and returning the resulting XHTML via a Stream Result. The response is different depending on the given parameters. Here is the action class with a bunch of stu...

how to execute a java program on several cores ?

Hi... I had a Java program that I run thousand times based on a loop (according to the number of files to be compiled to build a linux kernel) in a bash script. There was a performance problem since the jvm was started several times... What i've done then is implementing a wrapper in java that does the same as my bash script, reads on...

Java 6 Map.get() Type Safety Unexpected Behavior(?)

Possible Duplicate: What are the reasons why Map.get(Object key) is not (fully) generic According to the javadocs (http://java.sun.com/javase/6/docs/api/java/util/Map.html) for the Map interface, the definition of get is V get(Object key) Returns the value to which the specified key is mapped, or null if this ...

Java Swing BasicUI update error, what can I do ?

My program uses Swing JPanel, JList, JScrollPane ... It runs fine, but generated the following error message, and yet in the message it didn't say which line of my program caused the error, what can I do ? ========================================================================= Exception in thread "AWT-EventQueue-0" java.lang.ArrayIn...

Interpret something, and run the generated bytecode in Java?

I'm writing a toy interpreter with a REPL in Java. I'd like to generate bytecode from the language and run that, instead of interpreting an AST and running that instead. Since my Java is a bit rusty, is it possible to run generated bytecode on the fly on the JVM? ...

How can I handle an IOException which I know can never be thrown, in a safe and readable manner?

"The major difference between a thing that might go wrong and a thing that cannot possibly go wrong is that when a thing that cannot possibly go wrong goes wrong it usually turns out to be impossible to get at or repair." -Douglas Adams I have an class FileItems. FileItems constructor takes a file, and throws an exce...

OSGi and legacy libraries

I've been looking into OSGi for a while and I'm wondering about the best way to deal with "legacy" libraries (that are released as plain JARs, not as OSGi bundles). What do you think is the best way to handle these? Modifying their manifest file and adding the minimal bundle-specific information, then repackaging them is what I do at th...

java parse html + css and convert the output to different lang

Hello all i need to understand html + css files and convert it to somthing like rtf layot in java now i understand i need somekind of html parser but what i need to do from there ? how can i implement html-css convertor ? is there somekind of patern or method for such jobs? ...

Should validators in spring access the database?

I'm not really sure if it's a good design decision to make the validators validate commands based on the state of the database. For example if I need to validate a User bean besides checking if the email and username are empty etc. I also need to reject values if they are already used. Should this kind of logic go in the validators or th...

What is the jTDS JDBC Connect URL to MS SQL Server 2005 Express

I'm trying to connect to a MS SQL Server 2005 Express database that is running on the local host from a java program. I have tried the same connect URL (below) that I used on another system (same jave code) that was running MS SQL Server 2000. But that does not work. jdbc:jtds:sqlserver://127.0.0.1:1433/Finance Any ideas? ...

How to view/change socket connection timeout on Linux?

When creating a Socket in Java: new Socket(host, port); The Socket constructor will try to connect to host:port before returning. On Windows, this fails almost immediately for unreachable hosts but for Linux it can take up to 5 minutes for the Socket to timeout. I'm aware that if I have control over creating the Sockets, I can do: ...

A means of specifying pattern strings that drive parsing and formatting for arbitrary objects?

I'm building a general purpose data translation tool for internal enterprise use, using Java 5. The various departments use differing formats for coordinate information (latitudes/longitudes), and they want to see the data in their own format. For example, the coordinates of the White House in DMS format are 38° 53' 55.133" N, 77° 02...

JTable Column resize isn't working

table.getTableHeader().setResizingAllowed(false); column = table.getColumn(columns[0]); column.setWidth(25); column = table.getColumn(columns[1]); column.setWidth(225); column = table.getColumn(columns[2]); column.setWidth(50); table.doLayout() This refuses to set the columns to their specified widths. Any reason why? ...

Would one have to know the machine architecture to write code?

Let's say I'm programming in Java or Python or C++ for a simple problem, could be to build an TCP/UDP echo server or computation of factorial. Do I've to bother about the architecture details, i.e., if it is 32 or 64-bit? IMHO, unless I'm programming something to do with fairly low-level stuff then I don't have to bother if its 32 or 64...

JTable not returning selected row correctly

I am working with an extension of the DefaultTableModel as follows: This is the NEW AchievementTableModel after updating it to reflect input from some answers. public AchievementTableModel(Object[][] c, Object[] co) { super(c,co); } public boolean isCellEditable(int r, int c) {return false;} public void replace(Object[][] c, Object[]...

How to start a background Process in j2ee

Hi I want to start a background process in a j2ee (OC4J 10) envronment. It seems wron to just start a Thread with "new Thread" But I can't find a good way for this. Using a JMS queue is difficult in my special case, since my parameters for this method call are not serializable. I also thought about using a onTimeout Timer Method on a...

Java synchronize statement around a lock

I was wondering if synchronize (lock) { ... } Where lock is an instance of java.util.concurrent.locks.Lock, treats lock like any other object or as the try-finally idiom i.e. lock.lock(); try { ... } finally { lock.unlock(); } ...

How is this 13 bytes long?

Two quotes: All of the remaining messages in the protocol take the form of <length prefix><message ID><payload>. The length prefix is a four byte big-endian value. The message ID is a single decimal byte. The payload is message dependent. request: <len=0013><id=6><index><begin><length> The request message is fixed length, and...