java

Avoiding parallel inheritance hierarchies

I have two parallel inheritance chains: Vehicle <- Car <- Truck <- etc. VehicleXMLFormatter <- CarXMLFormatter <- TruckXMLFormatter <- etc. My experience has been that parallel inheritance hierarchies can become a maintenance headache as they grow. How do I avoid a parallel inheritance hierarchy without b...

Accessing resources locally in an applet on IE6

Was trying to follow http://java.sun.com/docs/books/tutorial/uiswing/components/icon.html when came across error. Seems that getResource returns null when accessing the page locally (i.e., when URL is, say, "C:\projects\html\test.html") in IE6. Class and resource are in same JAR file. Anybody know the reasons and a work-around (if one...

programming settings of a software using java

I'm building a restaurant system, and I want to give adminstrator a privilege to change and save the settings so that when other users log in, will find new settings. ...

How to implement a custom COM interface in Java

I need to pull some data from java into C#. I am already exposing my C# classes via COM. So I thought a good way to pull data from java would be to expose IReadStream from C# and implement IReadStream in java. I can then send an instance of the implementation as a parameter to C# so that I can call IReadStream.Read in C#. How do I imple...

Quick Swing question: Need to shut down my database on close

I've been building a test application that works with a database that up until recently has been without a UI. I'm adding one now. Problem is, the JFrame is launched in another thread and I need my database connection to close when that thread closes (when the UI closes, I should say). How do I do this? Also, what happens to the appl...

java program to divide an image file into 4 parts

I want to divide an image file into 4 parts using java i tried it but i am getting exceptions and also i want to store all the pixel values of image into an array. for this i used pixel grabber class but of no use.please help me ...

Java FileReader encoding issue

I tried to use java.io.FileReader to read some text files and convert them into a string, but I found the result is wrong encoded and not readable at all. Here's my environment: Windows 2003, OS encoding: CP1252 Java 5.0 My files are UTF-8 encoded or CP1252 encoded, and some of them (UTF-8 encoded files) may contain Chinese (non-La...

Macbook Security Alarm Task

I intend to put my macbook on my landing/hallway for when the people downstairs come up to rummage through my bedroom/rooms, such that when an intruder is detected a set of scripted events occur, such as a countdown from 10 followed by very loud music, but the existing software is either commercial or insufficient. Im not intending to sp...

How to select nodes in Netbeans Visual Library?

I create a graph based visual applicaion using a Netbens Visual Library. Can somebody post a code sample that enables a selection of nodes with mouse clicks (and Ctrl key fo multiple selection) ? Thanks in advance. ...

Retrieve column names from java.sql.ResultSet

With java.sql.ResultSet is there a way to get a column's name as a String by using the column's index? I had a look through the API doc but I can't find anything. ...

Java indexOf returns false for unfound string?

I need to know whether in Java does the indexOf() method return false or void for an unfound string? or does it return an index int of 0? ...

How to install Apache Ant?

I want to install SMSlib (http://smslib.org/) in installation instruction (http://code.google.com/p/smslib/wiki/Installation). In here I must install Apache Ant, but I didn't understand how to do that. I already download Apache Ant 1.7.1 , read manual (http://ant.apache.org/manual/index.html) In here I must have RPM version from jpac...

For what reasons do people choose Ruby over Java?

I am a beginner to Ruby. I've heard the following complaints about Ruby, and was hoping the Stack Overflow community could address each point raised. Common complaints about Ruby that I've heard: Ruby is slower than Java Ruby is not statically typed It's not suitable for large projects Given these admittedly opinion based statement...

Use of ajax to call JMS

Hi I have the followig code: page1.jsp The ajax function called on click of button function ajaxFunction() { var xmlHttp; xmlHttp = new ActiveXObject("Msxml2.XMLHTTP"); xmlHttp.onreadystatechange=function() { if(xmlHttp.readyState==4) { alert("Data loaded"); } } xmlHttp.open("GET","page2.jsp",true); xmlHttp....

Increasing Heap size for SQuirreL SQL on Max OS X

Hi, I'm running SQuirreL SQL (2.6.8) on Max OS X. I'm running out of heap space when trying to create a Table script. Can anyone tell me how to configure SQuirreL SQL to start up with a higher jvm heap size? I'm rather new to developing on Macs, so assume I'm ignorant. Thanks. ...

Fast circle collision detection

I'm trying to write a method that will calculate if two circles are overlapping. I've come up with the following and I'm just curious to know if there is anyway it could be optimised further. private static boolean isCollision(Point2D p1, float r1, Point2D p2, float r2) { float a,dx, dy; a = (r1+r2) * (r1+r2); dx = (float) (p1.getX()...

JPA @OneToMany Sets and unique contstaints

I have the following scenario: I have a system full of users. There is a desire to run contests for users who log into the site over a week or so. Therefore I needed to create a new Contest object which would contain both the entries and the winners. I created something like this: private Set<User>; @OneToMany(cascade = CascadeType....

How do I programmatically find out my PermGen space usage?

I'm trying to diagnose a java.lang.OutOfMemoryError: PermGen Space error when running on Sun's Hotspot JVM, and would like to know how much PermGen space my program is using at various points. Is there a way of finding out this information programmatically? ...

Lock a file while writing it on the disk

I have two independant threads F1 and F2 (to be precise, two instances of java.util.concurrent.FutureTask) that are running in parallel. F1 do some processing, and then copy the result in a XML file. Then, it repeats these steps until it has nothing to do (many XML files are created). F2 looks in the F1 output directory, and take one fi...

How to integrate BIRT with Python

Has anyone ever tried that? ...