java

Convert a StreamWriter to an OutputStream in java ?

I am trying to redirect System.out into a String using System.setOut, which takes a PrintStream. Is there any way to convert a StringWriter into a Stream so that I can pass it to setOut? ...

before Warning login

i need to alert or warn the user.. while user login into particular account 'your account has been expired next week' like that.. my user table having validfrom and validto date. Before 1 week of validto date.. i need to warn users at every time login. my application using strus2.. for above business logic i need any schedular.. otherw...

Mocking a URL in Java

We have a URL object in one of our Java classes that we want to mock, but it's a final class so we cannot. We do not want to go a level above, and mock the InputStream because that will still leave us with untested code (we have draconian test coverage standards). I've tried jMockIt's reflective powers but we work on Macs and there are ...

Integer with leading zeroes

when i write System.out.println(0123); i get 83 however System.out.println((int)0123F); returns 123 why it works that way? ...

Java Applet - Image Export Performance Issues

I have a Java Applet that I'm making some edits to and am running into performance issues. More specifically, the applet generates an image which I need to export to the client's machine. This is really at the proof-of-concept stage so bear with me. For right now, the image is exported to the clients machine at a pre-defined location (T...

Why does my tomcat application's memory usage keep growing?

My application is running on Windows Server 2000. The memory usage keeps growing (from 145m). Is that normal? I am new to Java. The version is Tomcat5.5. ...

Best practices for Java logging from multiple threads?

I want to have a diagnostic log that is produced by several tasks managing data. These tasks may be in multiple threads. Each task needs to write an element (possibly with subelements) to the log; get in and get out quickly. If this were a single-task situation I'd use XMLStreamWriter as it seems like the best match for simplicity/funct...

A better class to update property files?

Though java.util.properties allows reading and writing properties file, the writing does not preserve the formatting. Not surprising, because it is not tied to the property file. Is there a PropertyFile class out there -- or some such -- that preserves comments and blank lines and updates property values in in place? ...

What conferences/training should an employer provide for a java/web team?

I'm a software developer at a large insurance company in Canada. Our dept. is looking at getting some training for us all. We are mostly a java group (JSF/JSP/Servlets) but obviously we use a lot of other web technologies (tiles, ajax, YUI ...etc). The main topics we're looking at are: JSF AJAX Web security Advanced Java/EE topics ...

Java Swing Table size problem

Hi, I'm having problems with JTables. I'm adding two tables to a panel, the tables are within a scrollpane, but when the app shows up, the tables always occupy more space than the number of rows, wasting my available space. I'm using groovy and swingbuilder to create the tables, here's the code: scrollPane(){ panel(layout: new Mig...

EJB is not found in lifecycle module when it is redeployed on GlassFish

Hi, I have an EJB deployed on my GlassFish v2.1 application server. I have also set up a lifecycle module within GlassFish which utilises this bean when it receives a READY_EVENT type. I have the following code to look up the bean: BusinessInterface bean = (BusinessInterface) initialContext.lookup("JNDI lookup name"); ... // do somet...

Easymock: does the order of captures matter?

This might seem like a pretty detailed question about Easymock, but I'm having a hard time finding a support site/forum/mailing list for this library. I'm encountering a bug when using the captures() method that seems to return the captured parameters out of order. Here's a simplified version of what I am testing: public class Capture...

JTable with a complex editor

I have many custom editors for a JTable and it's an understatement to say that the usability, particularly in regard to editing with the keyboard, is lacking. The main reason for this is that my editors are always created with a similar (though often more complex) situation to this: @Override public Component getTableCellEditorComponen...

Options for dynamic compilation in Java 5

Are there any options other than Janino for on-the-fly compiliation and execution of Java code in v5? I know v6 has the Compiler API, but I need to work with the v5 VM. I essentially need to take a string containing a complete Java class, compile it and load it into memory. ...

Ehcache / Hibernate and RMI replication with large number of entities

Hi All, I'm currently investigating how to use the RMI distribution option in ehcache. I've configured properly ehcache.xml and replication seems to work fine. However I've 2 questions: -> It seems ehcache/ hibernate creates 1 cache per Entity. This is fine, however when replication is in place it create 1 thread / cache to replicate...

Weird JUnit logging behavior

I'm noticing some weird behavior using standard logging during JUnit tests. Does JUnit redirect standard output to a different stream? How can I get access to that? Here's a simple JUnit test that demonstrates the behavior I'm describing. @Test public void logMessage() { // set up new logger with output directed to standard out ...

java and reflection

Is it possible to call a method by reflection from a class? class MyObject { ... //some methods public void fce() { //call another method of this object via reflection? } } Thank you. ...

JMX Thread stuck on ClientNotifForwarder

Our application connects to several jmx agents (about 50) to poll jmx data in frequent interval. After some time (about a day) application becomes irresponsive. We looked at thread dump and seeing large number of threads stuck on ClientNotifForwarder.. Eg: "ClientNotifForwarder-50" daemon prio=3 tid=0x09aa3800 nid=0x330 runnable [0xd3...

java.util.ArrayList<T>

This is the implementation of java.util.Arrays.asList: () public static <T> List<T> asList(T... a) { return new ArrayList<T>(a); } How can that compile? I can't find a constructor for ArrayList, AbstractList or AbstractCollection that accepts a parameter like T... och T[]. Source code from: java version "1.5.0_16" Java(TM) 2 Run...

BufferedImage Rotation

What is the best way of rotating a bufferedimage about its center where the gradient is 1 degree? I know there is AffineTransform, but that causes shearing and weird stretching or black spots that should be blank. edit The sizes of images I am dealing with are icon sizes, so typically 24x24 up to 48x48 pixels ...