java

What libraries are available to help create 2D Java games for phones?

I want to begin developing 2D Java games for phones (on J2ME) therefore I'd like to know if any libraries or "engines" exist to help out in the various graphical tasks: Drawing text with pixel fonts? Drawing bitmaps for sprites with multiple frames like animated GIFs? Drawing graphics with code, lines, beziers, flood-filling and gradie...

Java - SAX parser on a XHTML document

Hey, I'm trying to write a SAX parser for an XHTML document that I download from the web. At first I was having a problem with the doctype declaration (I found out from here that it was because W3C have intentionally blocked access to the DTD), but I fixed that with: XMLReader reader = parser.getXMLReader(); reader.setFeature("http://...

Restful web service in java

I have a project and i was trying to create a restful webservis. I searched a lot and almost finished all the net documentation. Always having a problem. Can someone say me a good webservis sample which has got server and client side in java? ...

JDialog cancel button

How can I set a cancel button in a Swing JDialog, i.e. a button whose action is performed automatically if the user presses the “Cancel” key on the keyboard? The counterpart is offered for a default action via the setDefaultButton method of the dialog's root pane. If that's helping, I'm searching for an analogue to the WinForms Form.Ca...

Maintaining application resource properties

What is the difference between maintaining application properties in plain java objects example: public class AppProp { public static final String RESOURCE_NAME="RESOURCE VALUE"; } and maintaining in seperate property file. I am asking this question based on memory and performance of accessing the resource. ...

Key events on application level in Java

Is it possible to be notified of key events on an application level and not on a Component level? What i mean by application level is not having a swing component receive key events but to have a special class listen to system wide key events. This could be used in an app with no GUI for instance or when a more global handling of key ev...

PreparedStatement is executed on prepareStatement on SQL Server

We have a Java code similar to the following: PreparedStatement stmt = connection.prepareStatement("drop login tmp"); int result = stmt.executeUpdate(); When running through a debugger, it seems that our SQL statement is executed after the first line is executed, and even before the second line is executed. When the second line is exe...

Java- && doesn't seem to be working in a while loop...

NEVER MIND- IT WAS MY OWN DUMB MISTAKE, CONFUSED THE VARIABLES I have the following while loop: while (((pi.getFunds() - rmiPrice) > 0) && (rmi.getInventory() > 0)) { } pi.getFunds() is a double that represents how much money a fictional object (pi) has, rmiPrice is a double that represents a price of a product (rmi) that pi wants ...

How can I force an XSLT result tree to serialize with a particular default namespace?

I'm trying to strip the namespace qualifiers from a document, while retaining the document namespace as the default: <foo:doc xmlns:foo='somenamespace'> <foo:bar /> </foo:doc> To <doc xmlns='somenamespace'> <bar/> </doc> (I know, this is meaningless, but our client doesn't get XML and uses string comparisons to find informa...

Java Execution Context Class Explain

I wanted to grab the concept of "Execution Context class" . I'm refering to this post at http://tinyurl.com/ryjn5o . Can anyone enlighten by explain more on how to create such class ? ...

Bucket sort code help

Hello. I have three questions about the following code; static void funct(int[] list) { final int N = 20; java.util.ArrayList[] buckets = new java.util.ArrayList[N]; for(int i = 0; i< list.length; i++) { int key = list[i]; if(buckets[key] = null) buckets[key].add(list[i]); } int k = 0 for(int i = 0;...

Are static methods good for scalability ?

Does static methods and class are good for scalability ? I think so static class/method improves scalability of application and instance methods doesn't scales much. So is it good programming practice to write static method where ever it is possible ? ...

Mutable or immutable class ?

I had read in some design book that immutable class improves scalability and its good practice to write immutable class wherever possible. But I think so immutable class increase object proliferation. So is it good of going immutable class or better go for static class (A class with all the methods static) for improve scalability ? ...

Key factors for designing scalable web based application.

Currently I am working on web based application. I want to know what are the key factors a designer should take care while designing scalable web based application ? ...

package java applet with minimal dependencies, autojar plugin for buildr?

I'd like to build a java applet with all its dependencies included, but still keeping the jar as small as possible. I'm using buildr. It looks like autojar is the tool I'm looking for. Now I need to integrate the two. This is what I have: package.enhance do |p| p.enhance do |pkg| tempfile = pkg.to_s.sub(/.jar$/, "-unstripped.j...

Java PBEWithMD5AndDES

I am using password based encryption. My initial thought was to use AES to encrypt the file which contains passwords. Turns out password based encryption does not support AES. It uses DES. AFAIK des is not secure. Is PBEWithMD5AndDES secure enough to thrust my data or should i look for another implementation? ...

javax.resource.spi.work.ExecutionContext

any example on usage of javax.resource.spi.work.ExecutionContext ? ...

Java mysql connection time

I have a java program running 24/7. It accesses mysql database every 3 seconds only from 9.am to 3.PM. In this case when should I should open and close the MySql connection? Should I open and close every 3 sec? Should I open at 9.am and close at 3.pm? Should I open once when the program start and never close it. But reconnect when conn...

java.nio.channels.OverlappingFileLockException occurring randomly when attempting to embed applet?

Has anyone ever seen this odd error when attempting to load an applet? I get this in jconsole, although the applet activity is pretty plain. I get this exception after java.lang.NullPointerException at sun.plugin.AppletViewer.loadJarFiles(Unknown Source) ...

final variable in for statement in Java 5 and 6

Any idea why this compiles in Java 5 but not in Java 6? for(final int k=0; k<10; k++); What's the logic behind this? Any change to the scope of the variables between Java 5 and 6? I cannot find anything in Sun documentations regarding this. ...