java

java.net.SocketException: Broken pipe

I am getting this for all the database connections from my app server.. This exception occured for couple of hours, then got fixed by itself. Something to do with network connection from the appserver? java.net.SocketException: Broken pipe com.inet.tds.SQLException: java.net.SocketException: Broken pipe java.net.SocketException: Broken...

Implementing C# for the JVM

Is anyone attempting to implement C# for the JVM? As a Java developer, I've been eyeing C# with envy, but am unwilling to give up the portability and maturity of the JVM, not to mention the diverse range of tools for it. I know there are some important differences between the JVM and CLR but is there anything that is a showstopper? ...

What is the correct way to read a MIME encoded stream?

I have a TCP socket with streaming MIME messages on it. I can use the JavaMail API to parse one MIME message at a time by searching for the boundary, then looking for the boundary + -- symbol. This seems like a lot of String manipulation. Someone out there has to have done MIME-encoded streaming correctly in Java. Where is it hiding? ...

Castor 1.2 for POJO to XML

I am using Castor 1.2 for marshalling. Do you have any experience with using Castor for this purpose? Do you have suggestions for improving performance? ...

Returning a host object in Rhino

What is the best way to return an host object to JavaScript in Rhino? I have two classes like this: public class Hosted extends org.mozilla.javascript.ScriptableObject { private static final long serialVersionUID = 1; public Hosted() {} public void jsConstructor() {} public String getClassName() { return "Hosted...

Rotation and Scaling -- How to do both and get the right result?

I've got a set of Java2D calls that draw vectors on a graphics context. I'd like for the image to be doubled in size and then rotated 90 degrees. I'm using the following code to do this: Graphics2D g2 = // ... get graphics 2d somehow ... AffineTransform oldTransform = g2.getTransform(); AffineTransform newTransform = (AffineTransform)...

Invoke static initializer

Once a class is loaded is there a way to invoke static initializers again? public class Foo { static { System.out.println("bar"); } } Edit: I need to invoke the static initializer because I didn't write the original class and the logic I need to invoke is implemented in the static initializer. ...

Apache ant manifest class-path ?

I have a standard project layout for a java project: project / src / source_file_1.java ... source_file_N.java build / classes / source_file_X.class ... jar / MyJar.jar lib / SomeLibrary.jar SomeOtherLibrary.jar As far...

IE7 vnd.ms-excel popup disappears

I am using Java servlets and a custom framework which has options to download generated reports in various formats (CSV, PDF, XML Spreadsheet). This is done through a popup but does not seem to work when using content type of application/vnd.ms-excel in IE7. The popup appears but closes immediately. I have followed suggestions of settin...

Exception handling and memory

This may be a strange question, but do 'try-catch' blocks add any more to memory in a server environment than just running a particular block of code. For example, if I do a print stack trace, does the JVM hold on to more information. Or is more information retained on the heap? try { ... do something() } catch(Exception e) { e.pri...

Java: How do I use a PriorityQueue?

How do I get a PriorityQueue to sort on what I want it to sort on? Added: And is there a difference between the offer and add methods? ...

Android IllegalThreadStateException in LunarLander

Hey, Just come to polishing my application and making it resume after the user has left. When the application restores I get an IllegalThreadStateException, which is quite annoying. This problem is present in the example google gives of Lunar Lander. Has anyone found a way to restore working when using surfaceView? Cheers ...

Setting cookie in javabean getter

I am using Stripes but i'm not sure if this problem is because of that. I have an actionBean with a setter method setSearchView. In this setter, I set a cookie. The problem I'm seeing is that if i call that method from my jsp, the cookie does not get set (i have debugged the code and it does go through the code). If i call the same s...

Launch Application in a minimized state from Java

This is a followup question to one I previously asked: start-program-if-not-already-running-in-java I didn't get a great solution there (as there doesn't appear to be one), but I have a related question: Is there anyway to launch an application in Java code (an .exe in Windows, not a Java app) and have it start minimized? Or perhaps ...

Apache fop-0.95 error on FopFactory.newInstance() command

I am using Apache fop-0.95 to build pdf files from a JSP web application on IBM iSeries V5R4 using Websphere 6.0. Everything works perfect in my development using Websphere Development Studio client. When I put the application on the server, I get an error at this line. FopFactory fopFactory = FopFactory.newInstance(); The error ...

Use NetBeans to inspect live Java objects?

In Python, I'm used to being able to start a debugger at any point in the code, then poke around at live objects (call methods, that sort of thing). Is there any way, using NetBeans, to do this? For example, I'd like to be able to break at the line foo = bar().baz().blamo() and run bar(), bar().baz() and bar().baz().blamo() to see what...

Using XOM with NetBeans

I am attempting to install XOM so I can use it in my Java apps. The only problem is, I don't know where I can place it so NetBeans can find it. It would make sense to put it where the other .classes files are, but I can't seem to find them either. The README file for XOM says to install it to the Classpath variable, but I don't know wha...

Java Class that implements Map and keeps insertion order?

I'm looking for a class in java that has key-value association, but without using hashes. Here is what I'm currently doing: Add values to a Hashtable Get an iterator for the Hashtable.entrySet(). Iterate through all values and: Get a Map.Entry for the iterator Create an object of type Module (a custom class) based on the value. Add t...

Type aliases for Java generics

I have a fairly complicated set of generic classes in Java. For example, I have an interface interface Doable<X,Y> { X doIt(Y y); } and the implementation class DoableImpl implements Doable<Foo<Bar<Baz,Qux>>,Foo<Bar<Zot,Qux>>> { Foo<Bar<Baz,Qux>> doIt(Foo<Bar<Zot,Qux>> fooBZQ) { ... } } In the real implementation, Doable has qu...

Writing Simple and Efficient Database Custom ORM Code in Java

I have a Java object that I want to store in a local in-memory database. The Object has a One-Many FK relationship, otherwise it has 20 or so Integer/String/Enumerated fields. I would like to avoid using a framework. Even though the objects themselves are not very large, there will be a large amount of these objects being inserted/u...