java

Troubles Iterating Over A HashMap with JSF, MyFaces & Facelets

Hi all, I'm having some trouble looping over a HashMap to print out it's values to the screen. Could someone double check my code to see what I'm doing wrong. I can't seem to find anything wrong but there must be something. In a servlet, I am adding the following to the request: Map<String, String> facetValues = new HashMap<String, ...

How do I manage dynamic dependencies with PicoContainer?

Say I have two classes A and B, with B depending on A. public class A {} public class B { public B(A a) {} } It's easy to resolve B in a single PicoContainer. final MutablePicoContainer root = new PicoBuilder().build(); root.addComponent(new A()); root.addComponent(B.class, B.class); System.out.println(root.getCo...

Java Swing - how to show a panel on top of another panel?

I wish to have an internal (non window) dialog to ask for member input. I would like the dialog to be placed centrally on an existing JPanel. I have looked at layeredpanes and these seem unusable due to only having a single layout manager (or no layout manager) across all the panes. I guess I could try to override JLayeredPane and provi...

Convert VB's Val to Java?

How to implement VB's Val() function using Java programming language or is there any API that has the same method? ...

Command line progress bar in Java

I have a Java program running in command line mode. I would like to display a progress bar, showing the percentage of job done. The same kind of progress bar you would see using wget under unix. Is there a library to make this possible ? ...

Modernize I5/As400 program with Java

I have been given the task of modernizing my company's I5 based point of sale system. The main push is to create a friendlier interface/better data views without losing business logic. Is there a good Java way of interacting with an interactive (non-command line) I5 program? Something alone the lines of what PHP provides with their 52...

What is wrong with the short circuit logic in this Java code?

Why doesn't func3 get executed in the program below? After func1, func2 doesn't need to get evaluated but for func3, shouldn't it? if (func1() || func2() && func3()) { System.out.println("true"); } else { System.out.println("false"); } } public static boolean func1() { System.out.println("func1"); return...

Any good Spring threading with a TaskExecutor examples?

I'm trying to get a handle on how to implement threading in a Java application that uses Spring for transaction management. I've found the TaskExecutor section in the Spring documentation, and ThreadPoolTaskExecutor looks like it would fit my needs; ThreadPoolTaskExecutor This implementation can only be used in a Java 5 environm...

Why do we have to increase the Java Heap?

I know how to set the Java heap size in Tomcat and Eclipse. My question is why? Was there an arbitrary limit set on the initial heap back when Java was first introduced so the VM wouldn't grow over a certain size? It seems with most machines today with large memory space available this isn't something we should have to deal with. Than...

Java ArrayList and HashMap on-the-fly

Can someone please provide an example of creating a Java ArrayList and HashMap on the fly? So instead of doing an add() or put(), actually supplying the seed data for the array/hash at the class instantiation? To provide an example, something similar to PHP for instance: $array = array (3, 1, 2); $assoc_array = array( 'key' => 'value'...

Why does PrintStream.close() end up getting called twice?

Somewhat to my surprise, the following code prints out "Close" twice. Running through the debugger, it seems MyPrintStream.close() calls super.close(), which ends up calling MyPrintStream.close() again. import java.io.*; public class PrintTest { static class MyPrintStream extends PrintStream { MyPrintStream(OutputStre...

new Date("05-MAY-09 03.55.50") is any thing wrong with this ? i am getting illegalArgumentException

new Date("05-MAY-09 03.55.50") is any thing wrong with this ? i am getting illegalArgumentException ...

Java Socket Programming - Address already in use (errno=98)

Hi all, I'm try to write a basic server-client java application. However, I alway got a message of "socket bind on 10 for port 13244 failed: Address already in use (errno=98)" error no matter what port I'm using. I have attach a source code of my application, just wondering is there very stupid mistake I'm making. Many Thanks! Cheers...

What is the minimal configuration for REST-fully annotated service built on Spring 3 (m3)?

I'm trying to expose a REST-full service (hosted by Tomcat) and can't figure out what is the required configuration for Spring 3 (M3). This is how (example) the service looks like: @Controller @Scope("prototype") public class UsersController { @RequestMapping(value="/users/hello", method=RequestMethod.GET) public String hello()...

Convert single char in String to lower case

I like to 'guess' attribute names from getter methods. So 'getSomeAttribute' shall be converted to 'someAttribute'. Usually I do something like String attributeName = Character.toLowerCase(methodName.indexOf(3)) + methodName.substring(4); Pretty ugly, right? I usually hide it in a method, but does anybody know...

JTable Scrolling to a specified row index

I have a JTable that is within a JScrollPane. Rows are added to the table at runtime based on events that happen in my application. I want to have the scoll pane scroll to the bottom of the table when a new row is added to the table. For JLists There is the ensureIndexIsVisible() that forces a particular index in the list to be visible....

WYSIWYG text editor in Java

I'd like to collect all WYSIWYG text editors for Java here. Some rules for entries: There must be a link to the project/product You must state whether it's open source or commercial Is it possible to extend the editor (add new features like a "violet centered sudoku")? Is that simple or complex? Does it come with lots of features (fan...

JPA Map<String,String> mapping

How can I map a Map in JPA without using Hibernate's classes? Thanks in advance. ...

Is there a lazy loading implementation of JList ?

Hi, Is there a way to make a lazy loading with Swing JList ? Cheers, ...

Create a Cabinet file in Java

Hi, does anyone know a library that makes it possible to create a cabinet file in pure Java? ...